Introduction (pain point analysis)
As an architect or developer of an e-commerce platform, are you anxious about the big promotion spike every year? When the clock strikes zero, a huge number of users instantly influx, whether your system is facing the following serious challenges:
- -Flow pulses, system crashes.Instantaneous traffic is a hundred or even a thousand times that of weekdays, database connection pools are exhausted, and server CPU/IO soars to 1001 TP3T, directly leading to page jamming and service downtime.
- -Overselling is inconsistent with the data.Under high concurrency, the traditional inventory deduction logic is highly susceptible to concurrency problems, resulting in the inventory becoming negative (oversold), which seriously damages the enterprise reputation and user experience.
- -Synchronization blocking and slow response.The user order request needs to be synchronized to complete the inventory check, order creation, payment initialization and other time-consuming operations, any one link blocking will lead to user waiting timeout, churn rate surge.
If you're struggling withHow to smoothly, reliably, and efficiently respond to massive spike concurrent requestsAnd troubled, then Tencent Cloud's asynchronized peak-shaving solution based on the message queue CKafka will provide you with a complete and scalable best practice.
Solution Architecture Diagram and Overview
The core of this program is“Layered peak shaving and asynchronous decoupling”. Separate the user's instantaneous order request from the complex business processing in the back-end, and smooth out the traffic pulses by using the message queue CKafka as a powerful buffer pool to guarantee the stability of the core system.
Architecture Diagram.

Workflow Overview.
- Request Access.User spike requests first pass through the global acceleration link and are distributed to multiple front-end business servers by CLB load balancing.
- Pre-calibration.The front-end server (CVM/EKS) performs lightweight logic such as user eligibility, parameter validation, and quick querying of inventory balances via Redis. After the validation passes, the order information is used as a message bodyImmediate write to CKafkaAnd respond quickly to users “in the queue”.
- Chipping away at the peaks and filling in the valleys.CKafka clusters take over all transient traffic with their high throughput and persistence capabilities, enabling perfect traffic clipping.
- Asynchronous consumption.The downstream cloud function SCF or elastic microservice TEM acts as a consumer, pulling messages from CKafka at a controlled rate and smoothly executing final consistency operations such as inventory deduction and order drop.
- Data persistence.After processing, the results are written to the cloud database (MySQL/CynosDB) and the cache state in Redis is updated.
Core Products and Components
| assemblies | play a role | Key configuration/selection recommendations | Why choose it |
|---|---|---|---|
| Message Queues CKafka | system core buffer, assuming the key role of peak shaving and decoupling. | Suggested choiceshigh level specification, guaranteeing bandwidth and throughput; the number of partitions should be set larger than the number of consumers to enhance concurrent consumption. | With extremely high throughput and scalability, compatible with the Kafka ecosystem, seamless integration of various types of big data tools, managed services maintenance-free. |
| Cloud Server CVM / Elastic Container Service EKS | Front-end business logic processing, which is responsible for request validation, token generation and message production. | adoptionvolumetric billingmode and paired withElastic Stretch Group (AS)The system automatically scales up and down according to the CPU pressure. | Provides stable and reliable computing power, and elastic scaling ensures that resources are automatically adjusted before and after the spike, resulting in significant cost savings. |
| Cloud Database Redis | Hot Data Cache, storing seconds inventory, user blacklists, frequency limits, etc. | optionmemory-basedSpecifications.Enabling Persistence; Use Lua scripts to ensure atomic deduction of inventory. | Single-threaded memory operation with very high performance (10W+ QPS) is a great tool for dealing with highly concurrent reads and writes. |
| Cloud Function SCF | asynchronous task consumer, pulls messages from CKafka and handles the core ordering logic. | reasonableconcurrent executionsandNumber of messages batch processedto avoid overstressing the downstream database. | event-drivenWith the serverless architecture, it automatically expands and shrinks its capacity according to the volume of message pile-up, realizing true pay-as-you-go and maintenance-free. |
| Cloud Database TencentDB for MySQL/TDSQL-C | Final data storage, persistent storage of orders, products, and other information. | adoptionHigh Availability Editionso much so thatThree-Node Enterprise Edition, guaranteeing data consistency; it is recommended to useread-write separationArchitecture. | Providing highly available and high-performance database services, TDSQL-C (CynosDB) is especially suitable for massive concurrent write scenarios with excellent price/performance ratio. |
| Load Balancing CLB | single entry point for traffic, enabling traffic distribution and high availability. | optionHigh-performance version, supports massive concurrent connections. | Eliminate single points of failure and ensure high availability at the access layer. |
| Web Application Firewall WAF | security guard, defending against CC attacks, malicious swiping and other behaviors. | configurePrecise CC protectionrules andhuman-computer verificationpolicies, front-loaded to filter malicious traffic. | Intercepts the vast majority of attacks before traffic enters the business system, safeguarding campaign fairness and business security. |
Summary of program benefits
- ⚡ The ultimate user experience.Fast response to user requests (milliseconds), no need to wait for a long time, no lag in the system, and a smooth ordering process.
- ? ️ High system availability and stability.The back-end system is decoupled from traffic peaks, database and service pressure is always smooth, completely avoiding avalanche downtime due to overload.
- ? Flexible scaling for cost optimization.All components are elastically scalable, eliminating the need to purchase large amounts of idle resources for peak traffic and dramatically reducing IT O&M costs.
- ? Final consistency of data.With message queuing and reliable consumption logic, it ensures that the data for inventory deduction and order generation are ultimately consistent under high concurrency, eliminating overselling.
- ? ️ Architecture decoupled, flexible and scalable.The responsibilities of each module are clear, and the future expansion of new features (such as points deduction, SMS notification) only need to add new consumers, without changing the mainstream process.
Application Scenarios and Applicable Customers
- Typical Scene.E-commerce platform's 618, double 11, double 12 and other big promotion spike activities; new product debut rush; ticket system's popular venues to grab tickets.
- Applicable Customers.
- All Internet businesses that face cyclical or predictable traffic floods.
- Average daily PV of more than one million, rapid business growth, the need for highly flexible architecture of the e-commerce platform.
- Technical team looking to migrate from a self-built, hard-to-maintain spike system to a fully hosted, highly reliable cloud-native architecture.