Back to feed
Dev.to
Dev.to
6/23/2026
[System Design] Chapter 2: Flash Sale Engine - Solving Overselling and Hot Keys

[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?

Comments

Failed to load comments. Please try again.

Explore more