How a Single Redis Lua Script Prevents Double Bookings in Flash-Sale Systems

A software architecture series details how to build a flash-sale seat reservation system on AWS that guarantees no seat is ever sold twice. The core mechanism is a single atomic Redis Lua script that sequentially checks candidate eligibility, level capacity, and overall seat availability before confirming any booking. Four potential failure modes — double rollbacks, lost replies, crashed requests, and failover gaps — are each addressed with specific safeguards such as idempotency nonces, pending admission lists, and replica write confirmation via Redis WAIT. The system enforces three strict invariants: level and global seat caps are never exceeded, each candidate holds at most one active booking, and no admitted seat goes unresolved. Configuration details like setting Redis to noeviction mode and normalising candidate codes are highlighted as critical to maintaining data integrity under high concurrency.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in