Global High-Throughput Flash Sale
Spike-resistant drop architecture handling 250k+ global requests/sec with zero overselling using a CloudFront waiting room, Redis Lua atomic counters, DynamoDB 10-minute holds, and SQS FIFO order buffering.
- CloudFront waiting room
- Redis Lua atomic DECR
- SQS FIFO order buffer
- DynamoDB TTL reclaim
Amazon Route 53
Route 53 Anycast & Latency DNS
AWS Shield
AWS Shield Advanced
AWS WAF
AWS WAF Bot & Rate Gate
Amazon CloudFront
CloudFront Waiting Room & Static Edge
Amazon Simple Storage Service
S3 Static Drop Storefront
Amazon API Gateway
API Gateway Checkout Ingress
Amazon Cognito
Cognito Buyer Identity
AWS Fargate
Fargate Inventory Reservation API
Amazon ElastiCache
ElastiCache Redis Atomic Stock Counter
Amazon DynamoDB
DynamoDB Idempotency & 10-Min Holds
Amazon Simple Queue Service
SQS FIFO Order Buffer Queue
AWS Fargate
Fargate Payment & Ledger Worker
Amazon Aurora
Aurora PostgreSQL Financial Ledger
Amazon EventBridge
EventBridge Order & Expiry Bus
AWS Lambda
Abandoned Cart Stock Reclaimer
Amazon Simple Notification Service
SNS Buyer Confirmation & Alerts
Amazon CloudWatch
CloudWatch Real-Time Drop Telemetry
The problem
When 500,000 global buyers compete for 10,000 limited items at 12:00:00 UTC, SQL `SELECT FOR UPDATE` locks collapse under contention. The architecture must block bots at the edge, decrement stock atomically in under 1ms with zero oversells, and reclaim unpaid carts automatically.
Step-by-step flow
Edge bot scrubbing and virtual waiting room
Shield Advanced and WAF filter bot traffic while CloudFront serves the static drop page and a 1-second cached S3 stock badge. A CloudFront edge function meters buyers into checkout with signed admission JWTs.
Route 53 · Shield Advanced · WAF · CloudFront · S3Idempotent buyer check and atomic Redis Lua reservation
Fargate writes a conditional hold (`attribute_not_exists`) in DynamoDB keyed by `userId#dropId` (10-min TTL) to enforce 1 unit per buyer, then executes a single-threaded Redis Lua script (`if stock > 0 then decr`) in under 1ms.
API Gateway · Cognito · Fargate · DynamoDB · ElastiCache RedisSQS FIFO buffering and paced ledger settlement
Successful reservations enqueue into SQS FIFO and return `202 Reserved` immediately. Fulfillment workers drain the queue at a steady pace, charge the payment provider, and commit settled orders to Aurora PostgreSQL.
SQS FIFO · Fargate · Aurora PostgreSQL · EventBridge · SNSAutomatic stock reclaim on expired holds
If a hold goes unpaid for 10 minutes, DynamoDB TTL expires the record and triggers a Lambda consumer on DynamoDB Streams to increment the Redis stock counter back up.
DynamoDB · Lambda · ElastiCache Redis · CloudWatch
Key decisions & benefits
Redis Lua atomic decrement instead of SQL row locks
Executes `EVALSHA` check-and-decrement in ElastiCache Redis instead of locking hot SKU rows in PostgreSQL.
Why it works: Processes tens of thousands of stock checks/sec in under 1ms with zero lock contention.
Two-phase checkout (10-min hold + SQS FIFO) before Aurora commit
Separates fast inventory reservation (Redis + DynamoDB) from slow payment gateway calls and Aurora ledger writes.
Why it works: Instant buyer feedback while Aurora PostgreSQL sees a flat, spike-free write load.
1-second S3 stock snapshot cached at CloudFront
Publishes a tiny `stock.json` file to S3 every second with `s-maxage=1` behind CloudFront.
Why it works: Collapses 250,000 status polls/sec into 1 origin read/sec.
DynamoDB `userId#dropId` check before Redis decrement
Runs the DynamoDB conditional put before decrementing Redis so duplicate tabs fail early.
Why it works: Prevents one user or script from locking multiple units of inventory.
AWS services used (16)
Amazon Route 53 Global DNS
Routes buyers to the closest edge.
AWS Shield DDoS Protection
Absorbs volumetric drop floods.
AWS WAF Bot & Rate Gate
Blocks scalper scripts at the edge.
Amazon CloudFront Waiting Room CDN
Caches drop pages and meters admission.
Amazon S3 Static Storefront
Hosts UI and 1s stock snapshot JSON.
Amazon API Gateway Checkout Ingress
Validates buyer and admission JWTs.
Amazon Cognito Buyer Identity
Ties 1-per-user limit to verified accounts.
AWS Fargate Checkout Compute
Pre-warmed reservation and worker fleets.
ElastiCache Redis Atomic Counter
Sub-ms Lua stock check-and-decrement.
Amazon DynamoDB 10-Min Holds
Conditional 1-per-buyer lock + TTL.
Amazon SQS FIFO Order Buffer
Smooths checkout spikes into flat workers.
Aurora PostgreSQL Order Ledger
ACID relational storage for settled orders.
AWS Lambda Stock Reclaimer
Restores expired DynamoDB holds to Redis.
Amazon EventBridge Order Bus
Routes settled order events.
Amazon SNS Buyer Alerts
Sends receipt emails and SMS notifications.
Amazon CloudWatch Drop Telemetry
Tracks stock invariant and queue depth.
Trade-offs
| Choice | Benefit | Trade-off |
|---|---|---|
| Redis Lua hot inventory gate | Sub-millisecond atomic stock reservation. | Requires Multi-AZ failover and rebuilding count from DynamoDB holds on node loss. |
| DynamoDB 10-minute TTL stock reclaim | Event-driven recovery without polling cron jobs. | DynamoDB TTL deletion can lag wall-clock expiry by a few minutes. |
| CloudFront virtual waiting room | Protects API Gateway and Fargate from overload. | Shows a queue screen during the opening second of a drop. |
| Pre-warmed Fargate reservation tasks | Zero cold-start latency at drop time. | Pays for idle vCPUs for 15–30 minutes around the drop window. |
Open to Backend & AWS Cloud roles
Hiring for AWS Cloud or Backend Engineering?
Available immediately (UTC+1) for remote roles, sponsored relocation, or B2B contracts.