Flash-sale inventory overselling prevention

DesignHard40 minShopify and Amazon style

Your task

An inventory service for a flash-sale platform must guarantee a unit of a limited-stock SKU is sold at most once across 60 app servers in two regions. The team currently uses a Redis distributed lock (single-node SETNX with TTL) around the decrement. Under load they occasionally oversell. Redesign the locking/coordination so overselling is impossible, and explain precisely why the current scheme fails.

It covers

  • Lease expiry
  • Fencing
  • Redlock critique