Dev.to
6/23/2026
![[System Design] Chapter 2: Flash Sale Engine - Solving Overselling and Hot Keys](https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftcc9g1eklyeiml6n4ig2.png)
[System Design] Chapter 2: Flash Sale Engine - Solving Overselling and Hot Keys
Short summary
Shopee prevents overselling during flash sales using a three-tier caching architecture: local RAM caches with 1-2 second TTL (blocks 90% of traffic post-sellout), Redis distributed cache for availability, and Lua scripts executing atomic inventory deductions. Inventory sharding across 10 Redis nodes distributes load. Pattern: layer local caches with distributed caches and use atomic transactions to safely handle millions of concurrent purchase attempts.
- •Three-tier caching: local flags → Redis → Lua atomic operations prevent overselling
- •Lua scripts execute as atomic transactions on single-threaded Redis; no race conditions
- •Inventory sharding across 10 nodes divides system pressure while maintaining consistency
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



