Single spike service to dubbo framework + distributed transaction implementation

Time:2022-9-23

Single spike service to dubbo framework + distributed transaction implementation

Scheme and technical architecture

Scheme: seckill scheme (

) + distributed transaction solution (for payment, deduction of inventory and order status consistency solution, see the figure below)

Purpose: Dubbo microservice realizes distributed transaction of order payment, unified submission and rollback

Technology Architecture:

docker + nacos architecture (remove zookeeper, nacos is more fragrant)

docker version 2.7

springboot version 2.6.1

Distributed transactions (tcc -transaction 1.73)

github address:https://github.com/luozijing/…

Project experience address:http://81.69.254.72:9082/logi…

Single spike service to dubbo framework + distributed transaction implementation

dubbo module split

The module is divided into admin (web controller and front-end page entry) + order (seckill order + inventory) + user (payment, user table) according to the above figure.

The order and users modules are divided into two sub-modules, the api and provider modules. The api is responsible for providing the interface and entity classes of dubbo, and the providers are responsible for providing the implementation of the api and related internal logic.

There is also a common public module, which provides common tool classes, including redis connection, zokeeper connection and other tool classes.

Features

User registration and login

The user registers an account id in the format of his mobile phone number, the password is at least 6 digits, and the account will initialize a virtual account of 2000, and the user will pay for subsequent orders.

After registration, you can log in, display the seckill interface, and select the product seckill, each type of seckill product does not exceed one.

Test account 15712341234/1234567

Single spike service to dubbo framework + distributed transaction implementation

Lightning Deals and Payments

After selecting a product for Lightning Deal, you can view the generated order. The order will lock the stock of Lightning Deal, but it will not actually deduct the stock.

Single spike service to dubbo framework + distributed transaction implementation

Make a virtual payment, and then the inventory will be deducted, the order status will be modified, and the virtual account amount will be reduced. For details, you can view the changes in the inventory on the page.

Single spike service to dubbo framework + distributed transaction implementation

Online deployment

Server: tx cloud 2c4g lightweight server, 1200G traffic,

Operating system: CentOS7.6-Docker20 of the system’s own docker

Deploy the module:

Single spike service to dubbo framework + distributed transaction implementation

According to the actual server configuration, configure the memory size of the java module and configure the server swap memory to ensure the stable operation of the service. The nacos is configured with 512M, the dubbo module has basically no business configuration with 128M, and the new generation is half. The configuration of docker one-click deployment is available in github, but the dubbo module needs to be compiled into the server to start.