Introduction (pain point analysis)

With peak traffic jumping from tens of thousands to millions or even billions, is your order system facing the following tough challenges?

  • Overwhelmed databasesTraditional relational databases (e.g., MySQL) quickly reach bottlenecks in IOPS and connection counts in the instantaneous mass writing of order requests, leading to soaring response latency and ultimately triggering system lag or even downtime, which directly affects turnover.
  • The Inventory Overselling Conundrum: In high concurrency scenarios, simple database transaction locks or application layer locks are very likely to fail, leading to “overselling” of inventory deduction, which seriously damages the platform's credibility and triggers customer complaints.
  • Poor system stability: Failure of a single service or database node can trigger an “avalanche effect” across the entire application chain, resulting in the entire service being unavailable and the user experience dropping to freezing point.

If you are suffering from system lag, overselling risk and high operation and maintenance costs caused by high concurrency orders, then this article will provide you with a complete solution based on Tencent Cloud's core products that have been battle-tested.

Solution Architecture Diagram and Overview

This program uses“Access layer flow limiting -> Cache layer interception -> Database layer persistence”The layered peak-shaving design ideas, the use of Tencent cloud a variety of core products to build a stable, efficient, elastic high concurrency order system.

architecture diagram

Double 11 Billions of Orders without Lag: Tencent Cloud TDSQL-C and Redis Distributed Cache Architecture Solution - LikaCloud

Workflow overview::

  1. The user's request first goes throughTencent Cloud API Gateway, performs authentication and precise flow limiting to block invalid and excessive requests out of the system.
  2. The requests that have passed the validation enter the business logic layer, and the core operation is to call the API.Tencent Cloud RedisThe Atomic Command pre-deducts inventory, solves overselling problems and takes the lion's share of concurrency pressure.
  3. After the inventory hold is successful, the order data is asynchronously written to the message queue, and finally, the consumer service smoothly writes it into the databaseTencent Cloud TDSQL-CPerform final persistence to avoid a hit to the database.

Core Products and Components

core componentplay a roleKey configuration/selection recommendationsWhy choose it
Tencent Cloud API GatewayTraffic Main Entrance and Defense. Responsible for authentication, authentication, flow control, caching and fusion of requests to protect the back-end business cluster from being overwhelmed.be directed against /createOrderisochronous interface configurationQPS current limit; turn onResponse Cacheto respond to repeated requests such as product information queries.Advanced traffic management can be realized without coding, providing highly available and flexible ingress layer services, which is the first guarantee of system stability.
Tencent Cloud RedisHigh Performance Cache and Inventory Control Center.. Undertake hotspot data caching (commodity information), and pass the DECRAtomic commands such as this one enable the withholding of inventory and solve the overselling problem once and for all.optionmemory-basedspecifications to ensure extremely high performance; it is recommended to turn onobjectificationfunction to prevent data loss; use theRedis Clustermode to scale capacity and performance.Provide stability and performance far beyond the self-built Redis, with automatic failover and online expansion capabilities, is the key to deal with instantaneous high concurrency read and write.
Tencent Cloud TDSQL-C (PostgreSQL Edition)Highly available data persistence engineResponsible for ultimately storing all order data securely and reliably. Responsible for ultimately storing all order data securely and reliably and is the “sole source of truth” for transactions.adoptionServerlessmode or compute node elasticity scaling to cope with traffic fluctuations;read-only instanceUndertake report-type queries to reduce the pressure on the main repository.The cloud-native architecture allows for extreme elastic scalability and cost-effectiveness, with excellent write performance and full compatibility with PostgreSQL, guaranteeing strong data consistency and high reliability.

Summary of program benefits

  • ⚡ Ultra-high concurrency processing: Redis in-memory operation with API gateway to limit the flow, easy to cope with millions of QPS instantaneous requests, to ensure that the order process is silky smooth.
  • ? ️ The data is absolutely reliable: Redis atomic commands eliminate overselling, and TDSQL-C provides financial-grade data persistence and high availability to ensure every order is accurate.
  • ? Ultimate cost optimization: The tiered architecture absorbs most of the stress in the lower-cost caching tier, and the elastic nature of TDSQL-C eliminates the need to pre-position large amounts of database resources for peak traffic, significantly reducing costs.
  • ? Simple and efficient operation and maintenance: Fully managed service eliminates the operation and maintenance troubles of the underlying infrastructure, supports flexible expansion and contraction, and allows the development team to focus more on business innovation.

Application Scenarios and Applicable Customers

  • Typical Application Scenarios::
    • E-commerce promotion seconds: Limited quantity of products in shopping festivals such as Double 11, 618, etc., and the issuance of red packets.
    • Ticket System Robbery: Online sales of popular tickets for concerts, events and more.
    • Explosive product debut: The online debut of new cell phones, popular shoes, and other products.
  • Applicable Customer Characteristics::
    • The business has significant peaks and valleys, with peak concurrent requests reaching 10,000 or more.
    • The data consistency requirements are so high that oversold and wrong orders are unacceptable.
    • Pursuing system stability and high availability, and wanting to build future-proof and resilient architectures.

Related links