The spike
A flash sale sends a huge burst of traffic at one product at the same instant. The hot inventory row becomes a bottleneck and naive checkout collapses.
Defenses
- Pre compute and cache the product page and price so reads do not touch the hot path.
- Shard the counter so deductions spread across sub counters that sum to the total.
- Token or coupon gating: issue a limited set of claim tokens equal to stock, then only token holders proceed.
- Queue admission so requests are admitted at a rate the inventory system can absorb.
Degrade gracefully
- Reject early with a clear out of stock signal rather than timing out.
- Make every step idempotent because clients will hammer retry.
- Keep payment off the hot path until a unit is actually claimed.
Key idea
Survive a flash sale by caching reads, sharding the hot counter, gating buyers with limited claim tokens, and admitting traffic at a rate inventory can absorb while failing fast when stock is gone.