Introduction (pain point analysis)
As an architect or developer of an e-commerce platform, do you have a love/hate relationship with upcoming big sales events? Campaigns such as spike and limited time rush can bring huge traffic and sales, but the technical challenges behind them are also headache-inducing:
- Instantaneous flow flooding.The moment the event starts, system traffic soars tens or even hundreds of times from the usual smooth state, and traditional fixed resource clusters are instantly overwhelmed, resulting in service unavailability.
- Resource costs and idleness.If you maintain a high-provisioning cluster year-round to cope with peaks, a large number of compute resources are idle during the inactive hours of 99%, resulting in a huge waste of cost.
- Inventory oversold risk.In high concurrency scenarios, multiple requests to query and deduct the same inventory at the same time, it is very easy to “oversell” (sell more than the actual inventory), which leads to serious capital loss and customer complaints.
If you're struggling with how to smoothly handle spike traffic and completely eliminate inventory overselling at a lower cost, then this article will provide you with a complete Serverless solution.
Solution Architecture Diagram and Overview
The following architecture diagram clearly shows the core composition and data flow of the spike system based on AliCloud Serverless Application Engine (SAE).

Architecture Overview.
The user request first passes through theLoad Balancing CLBandMicroservices Gateway MSEPerform traffic distribution and unified authentication. Core business logic (e.g., seconds, orders) is deployed in theServerless Application Engine SAEOn top of that, SAE can expand capacity extremely fast within 1 second according to the number of real-time concurrent requests to easily cope with traffic peaks, and automatically shrink capacity to 0 after the event to realize cost optimization.
The key spike request comes in and first visits theCloud Database Redis EditionPerforms pre-inventory deduction, utilizing Redis' atomic operations to ensure inventory accuracy. After a successful deduction, an asynchronous order message is generated and written to theMessage Queue RocketMQThe final order service in SAE consumes the message and asynchronously completes the database drop, greatly reducing the main databaseRDSThe pressure of the
Value Proposition.The program solves the resource cost and peak stability problems through the extreme elasticity of SAE, and fundamentally eliminates the overselling of inventory through the pattern of “Redis atomic deduction + asynchronous message queue”.
Core Products and Components
| component name | play a role | Key configuration/selection recommendations | Why choose it |
|---|---|---|---|
| Serverless Application Engine (SAE) | core computing engine, hosting microservice applications such as spike logic, order services, and more. | Recommended to turn ontiming elasticity(expanded before the start of the event) andIndicator elasticity(Dynamic scaling based on CPU/concurrency metrics). | No need to manage servers, provide second elasticity scaling, support shrinking to 0, pay per usage, perfectly match the second killing scenario. |
| Cloud Database Redis Edition | Cache Layer and Inventory Deduction Center. Cache hotspot data such as product details; byDECRWaiting for atomic commands to perform inventory deduction to avoid overselling. | optionmemory-basedSpecification guarantees high performance; recommended to turn onobjectificationIn case of data loss. | Providing ultra-high read/write performance and atomic operations on data is the key to solving the problem of highly concurrent inventory. |
| Message Queue RocketMQ | Asynchronous decoupling and peak shaving. Converts successful spike requests into asynchronous order messages to buffer transient traffic and protect downstream databases. | Recommended usesequential messageGuaranteed order processing sequence for the same item. | High throughput and high reliability, able to pile up massive messages to ensure that spike requests are not lost and the system is more stable overall. |
| Cloud Database RDS MySQL | Final data persistence. Stores product master data, final order information, etc. | optionHigh Availability Edition(one main and one standby) and select specifications based on the size of the operation. | Eliminate database operation and maintenance troubles, provide data reliability guarantee, with message queues to achieve the ultimate consistency. |
| Microservices Engine MSE | Microservices Gateway. Provides routing, authentication, flow limiting, and fusion capabilities, and is a unified entry point and security barrier for the system. | Configure for the spike interfaceaccurate limiting of traffic, preventing malicious requests from overwhelming back-end services. | Enhance system security, stability and observability to allow developers to focus more on business logic. |
Summary of program benefits
- 🚀 Seconds of resilience, never down.SAE can complete the instance expansion within 1 second, easily undertake million-level concurrency, to ensure that the service is always online during the event.
- 💰 Cost-optimized, pay-as-you-go.The service is billed according to the actual use of resources, and the capacity is automatically scaled down after the end of the activity, which reduces the resource cost by more than 70% compared with the traditional architecture.
- 🛡️ Eliminate overselling and protect capital losses.Redis-based atomic operation of inventory deduction, from the logical level to completely solve the overselling problem, to protect the interests of enterprises.
- 🔧 Operationally free and business focused.Fully managed cloud offerings free operations teams from infrastructure management to iterate on business functions more quickly.
Application Scenarios and Applicable Customers
- Core Scene.E-commerce platforms have instantaneous high concurrency activities such as seconds, limited time rush, new product debut, red packet rain and so on.
- Applicable customer characteristics.
- The business has significant peaks and valleys and seeks extreme resource utilization and cost optimization.
- Had been plagued with inventory overselling issues and had a high demand for data consistency.
- The development operations team has limited manpower and wants to minimize the complexity of infrastructure operations.