Introduction (pain point analysis)

As an architect or developer of an e-commerce platform, have you ever had sleepless nights on the eve of a “second sale” or “big promotion”? When millions of users click “Buy Now” at the same moment, is your system facing the following serious challenges:

  • Database pressure skyrocketed.Hot product information, inventory query requests instantly hit the database connection, resulting in an avalanche of services.
  • Inventory overselling conundrum.In a concurrent environment, the low performance of traditional database transaction locks can easily lead to incorrect inventory deduction and “overselling”, resulting in capital loss and customer complaints.
  • The response is extremely slow.User pages lagged and spun around, order requests were unresponsive for long periods of time, which ultimately led to the collapse of the user experience and the campaign was lost.
  • Malicious request attack.Scalper scripts and brushing tools seize normal user resources and destroy the fairness of activities.

If you are struggling with system stability, data consistency and user experience issues brought about by high concurrency spikes, then this article will provide you with a proven and complete AliCloud best practice solution.

Solution Architecture Diagram and Overview

The diagram below clearly shows how to build a robust secular system architecture using AliCloud products:

AliCloud Redis Helps Spike System: Best Practices for Hot Data Caching and Inventory Deduction - LikaCloud

The core design ideas of the program are“Layered interception, asynchronization, and eventual consistency”

Workflow.

  1. Traffic Access and Protection Layer.User requests are first routed through theEdge Security Acceleration (ESA)maybeCDNQuickly return to the static page resources, followed by theWeb Application Firewall (WAF)Cleaning malicious traffic.
  2. Business Logic Layer.net flowLoad Balancing (SLB)Distribute to stateless application servers (ECSmaybeFunction Calculation FC), perform basic checks such as user identity and grabbing eligibility.
  3. Core Cache and Deduction Layer.After the qualification passes, the server side calls theCloud Database Tair/Redis EditionIt atomically completes inventory inquiries and pre-deductions, and records the user's purchase status, returning results instantly.
  4. Asynchronous order processing layer.Successful requests for pre-deduction are sent as messages to theMessage Queues RocketMQ Edition, realizing traffic shaving. Downstream services consume messages asynchronously to complete time-consuming operations such as order creation and database persistence.
  5. Data persistence layer.​ ​Cloud Database RDS MySQL Editionas the ultimate data store, utilizing itsInventory HintFeature efficiently handles hotspot row updates to ensure eventual consistency with Redis.
  6. Full link monitoring.​ ​Application Real-time Monitoring Service (ARMS)Throughout, it provides full-link performance insights to help quickly locate bottlenecks.

Value Proposition.By digesting 99% read requests and inventory deduction operations in the cache layer and allowing only a small number of successful requests to enter the database, this solution completely solves the pain point in the introduction and realizes the ability to handle tens or even hundreds of thousands of second requests per second.

Core Products and Components

assembliesplay a roleKey configuration/selection recommendationsWhy choose it
Cloud Database Tair/Redis EditionThe core hub of the system. Undertake:
1.Hot Data Cache: Cache product details.
2.Inventory withholding: ByDECROrLuaScript Atomic Deduction Inventory.
3.request flow limiting (computing): ByINCREnables user/IP dimensional traffic limiting.
4.status mark: Use ofSETNXFlag users who have already placed an order to prevent duplicate purchases.
-selection: Selectionmemory-basedOrpersistent memory typeinstance, performance is prioritized.
-configure: Openobjectification(AOF) to prevent data loss on reboot.
-architecture: AdoptionCluster Editionarchitecture to easily scale performance.
Provides ultra-high throughput and atomic operations, with performance far exceeding that of databases. AliCloud version providesdata flashbackseamless expansion and contractionand other advanced features with simple operation and maintenance.
Message Queues RocketMQ Edition“Floodways” and “buffer zones” of the system. Undertake:
peak load shedding (meteorology): Convert instantaneous synchronous order placement requests into asynchronous messages that are sent smoothly to downstream order processing services to avoid the services being overwhelmed.
-selection: SelectionCluster Editionto ensure high availability.
-configure: Createsequential messageTopic, which guarantees the sequential nature of orders placed for the same item.
Extremely high throughput and reliable message stacking capabilities with support fortransaction message, ensuring that the business logic is ultimately consistent and ideal for asynchronized decoupling.
Cloud Database RDS MySQL EditionThe system's “ultimate data safe”. Undertake:
Final data persistence: Receive order information from the asynchronous Worker to complete the final stock deduction, order creation and other drop operations.
-characterization: Highly recommendedInventory Hintfeature, which improves performance several times when updating a single row of inventory at high concurrency.
-architecture: AdoptionHigh Availability Edition(Multi-Availability Deployment) Guaranteed Reliability.
As a mature and stable relational database, the ACID characteristics of the data are guaranteed.The Inventory Hint feature is specifically designed for thespike scene (computing)Optimization to solve the last performance bottleneck.
Edge Security Acceleration (ESA) / CDNThe “first barrier” to the system. Undertake:
Acceleration and protection: Cache static resources (HTML, CSS, JS, images) of active pages to intercept most user requests at the edge nodes, greatly reducing the pressure on the source site.
-configure: Setting a reasonable cache expiration time for the spike pagepreheatingandRefreshThe global node network provides millisecond response and integrates DDoS protection capabilities to enhance user experience while safeguarding security.
Web Application Firewall (WAF)The “security guard” of the system.. Undertake:
Brushproofing and Filtration: Accurately identify and block scalping scripts, CC attacks, SQL injections, and other malicious requests to protect the fairness of activities and business security.
-configure: Enablehuman-computer verificationCC SecurityCustomize precise access controlThe rule limits traffic against spike URLs.Provide comprehensive Web application protection for your business without modifying your business code, and easily meet the challenges of blackmail.
Application Real-time Monitoring Service (ARMS)The system's “Panorama Monitor”.. Undertake:
Full link observable: Monitor every request from the front-end API to the back-end Redis, MQ, and DB to quickly locate performance bottlenecks and anomalies.
-configure: for spike core interfaces, Redis commands, MQ heap case settingsBusiness OverviewandAlarm RulesProvides end-to-end performance monitoring capabilities to provide at-a-glance visibility into complex distributed systems, enabling rapid troubleshooting.

Summary of program benefits

  • ⚡ Extreme performance with millisecond response.Redis in-memory operation and asynchronization architecture, easy to cope with millions of QPS, the user ordering experience is smooth.
  • ? ️ Data is reliable and eliminates overselling.Redis atomic operations + Lua scripts guarantee accurate pre-deduction, combined with RDS transactions and Inventory Hint to ensure that inventory is ultimately consistent and never oversold.
  • ? ️ Flow shaving and system stabilization.RocketMQ asynchronous decoupling, effectively resisting transient traffic peaks, to protect the downstream database and services run smoothly.
  • ? Safe and compliant, fair and trustworthy.Through WAF, DDoS high defense and other means, it builds a three-dimensional protection system from the edge to the cloud, effectively identifies and intercepts malicious requests, and guarantees the fairness of activities.
  • ? Flexible scaling for cost optimization.All core products support on-demand elastic capacity expansion, and can be scaled down after the end of the campaign, effectively controlling costs.

Application Scenarios and Applicable Customers

  • Application Scenarios.
    • E-commerce promotion.Such as “Double 11”, “618” and other shopping festivals in the popular goods shopping.
    • Limited Edition.Such as the debut of new cell phones, limited edition sneakers, and concert tickets.
    • Timed Coupon Grab.Timed campaigns for platform coupons and red packets.
  • Applicable Customers.
    • All e-commerce platforms, online education, ticketing systems and other businesses facing high concurrency rush business.
    • Customers whose peak business traffic varies greatly from daily traffic and requires elastic resources to cope with it.
    • Clients who demand the highest level of data consistency and cannot tolerate overselling.

Related links