| With the rapid development of economic globalization and e-commerce,small and medium-sized e-commerce enterprises with limited resources bear more market uncertainty.Small and medium-sized e-commerce enterprises need to deploy their business models quickly and at low cost.This thesis focuses on the low-cost and rapid deployment of e-commerce platform through micro service architecture,and ensures the horizontal scalability,transaction throughput,elasticity and data consistency of the system.Improve transaction throughput and I / O efficiency through distributed cache technology,stabilize peak traffic through flow restriction strategy,realize system elasticity,and ensure data consistency through the data consistency solution of microservice architecture.This thesis has certain theoretical and practical significance for small and medium-sized e-commerce to deal with a series of problems caused by high concurrency.The specific work includes:(1)Based on the demand analysis and outline design of limited time rush purchase of micro services: focusing on the business characteristics of instantaneous and high concurrency of limited time rush purchase process,the interaction process between micro services is clarified by designing the system interaction structure;Describe the combination and reuse of system functions by abstracting the business architecture of time limited rush purchase system;Build microservices through the horizontal division of business functions,simplify the microservice architecture design of the limited time rush purchase system,and realize the horizontal expansion of the system;Abstract the non functional structure of the system and clarify the non functional constraints that the system needs to meet.(2)Expansion of distributed cache and peak flattening technology of current limiting strategy: relational database has become the I / O bottleneck of time limited rush purchase system.The introduction of distributed cache improves transaction throughput and I / O efficiency.Redis cluster scheme has the advantages of low cost and easy deployment,which is suitable for this system.The distributed current limiting scheme based on sliding window algorithm is designed and implemented to solve the current limiting failure problem of counting method;Combined with the local current limiting scheme based on token bucket algorithm,the peak flow is stabilized and the system elasticity is realized.(3)Solution to data consistency problem of microservice architecture: interface idempotency problem,oversold problem and distributed transaction problem caused by system peak traffic.Repeated calls to the write interface can easily lead to inconsistent data.Before calling the interface,the globally unique token is stored in the cache.When calling the interface,filter the repeated requests through the token,and ensure the atomicity of the token mechanism through Lua script.Distributed locks are introduced to avoid oversold.Redis distributed locks have problems of deadlock,false deletion and lock renewal.Deadlocks are avoided by setting the expiration time of locks;By setting the globally unique value for the lock and combining with Lua script,it can avoid deleting the lock by mistake;Renew the lock through the daemon thread.Microservices need to complete transactions through remote network cooperation,study and implement distributed transactions of two-stage Submission Scheme,TCC scheme and message queue scheme,and solve the empty rollback problem,idempotent problem and suspension problem of TCC scheme through transaction record table;By recording the local transaction status,the local transaction check problem of the message queue scheme is solved,and the three schemes are selected according to the test results.(4)Detailed design and implementation of the time limited rush purchase system based on microservices: the single architecture system lacks code isolation and horizontal expansion capabilities,and uses open source components to implement multiple independent microservices to adapt to the development of e-commerce business.The system focuses on the realization of commodity module,rush purchase module and order module,and carries out functional test and non functional requirement test on the above modules.The test results show that the system can meet the requirements of the actual application scenarios. |