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
docker + nacos architecture (remove zookeeper, nacos is more fragrant)
docker version 2.7
springboot version 2.6.1
Distributed transactions (tcc -transaction 1.73)
Project experience address:http://220.127.116.11:9082/logi…
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.
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
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.
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.
Server: tx cloud 2c4g lightweight server, 1200G traffic,
Operating system: CentOS7.6-Docker20 of the system’s own docker
Deploy the module:
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.