ArchitectAI resilience reviews are here. See what's new
Back to all articles
High Level Design Oct 16, 2026 14 min read

Designing Amazon Flash Sale: High-Concurrency Inventory & Checkout System

Surviving 1M+ simultaneous requests on a single product. Learn how to architect distributed inventory locking, Redis Lua scripts, and virtual waiting rooms.

HLDE-CommerceRedisConcurrencyKafka
HFHLDForge Architecture TeamPrincipal E-Commerce Architect

1. The Flash Sale Concurrency Challenge

When 100,000 units of a heavily discounted flagship smartphone are released at 12:00 PM, over 2 million buyers click 'Buy Now' within 500 milliseconds. Standard relational databases updating a single row (`UPDATE inventory SET count = count - 1 WHERE id = ?`) instantly deadlock due to row-level write contention.

The system must prevent over-selling, provide fair FIFO or lottery access, maintain low latency, and prevent downstream payment gateway collapse.

  • Peak Traffic: 1,000,000 requests per second targeting a single SKU
  • Inventory: Exactly 100,000 units available
  • Constraint: Zero overselling tolerance under any network partition
  • Latency Target: <200ms response time for reservation confirmation

2. Edge Protection & Virtual Waiting Room

Traffic is throttled at Cloudflare/CloudFront edge before hitting origin clusters. A Virtual Waiting Room allocates cryptographic signed queue tokens with an assigned entry time slot.

Static assets (product photos, descriptions, reviews) are served 100% from CDN edge caches with long TTLs, ensuring only reservation requests hit the application servers.

3. In-Memory Atomic Reservation with Redis & Lua

The source of truth for real-time inventory during the flash sale window is an in-memory Redis cluster. We execute an atomic Lua script that checks available stock, verifies the user hasn't already purchased the SKU, and decrements the counter in an atomic O(1) step.

If stock is available, a temporary reservation is created with a 10-minute TTL. The user is issued an encrypted `ReservationToken` to complete checkout.

4. Asynchronous Checkout & Event-Driven Fulfillment

Once payment succeeds, an `OrderPlaced` event is published to Apache Kafka. Fulfillment services consume messages asynchronously at a regulated rate, ensuring warehouse databases never experience traffic spikes.

If the payment fails or the 10-minute TTL expires, a compensating transaction automatically increments the Redis inventory counter back up.

Interactive Modeling ArchitectAI

Model this architecture on the HLDForge Canvas

Turn static box diagrams into living, collaborative systems. Drag and drop microservices, Kafka clusters, and cache tiers. Run automated SPOF detection and STRIDE threat modeling in real time.

HF

Written by HLDForge Architecture Team

Principal E-Commerce Architect

The HLDForge Architecture Team publishes practical engineering guides, real-world case studies, and high-concurrency blueprints to help engineers build scalable and fault-tolerant software.

Free forever plan

Ready to master distributed system design?

HLDForge gives you the tools, templates, and AI reviews to design systems like a Staff Engineer. Get started free.

SOC 2 Type II · ISO 27001 aligned · SSO on every paid plan