Overview
Design a flash-sale checkout, like a Ticketmaster drop or Prime Day, where 100,000 items sell out in seconds to millions of buyers and the stock never goes negative.
Requirements
- 01Survive 1M+ concurrent buyers hitting checkout at the moment the sale opens
- 02Never oversell. Stock cannot go below zero
- 03Hold an item in the cart for 10 minutes and release it if the buyer does not pay
- 04Keep bots out and give human buyers a fair chance, with a waiting room and queue tokens
- 05Confirm the order asynchronously after the payment gateway responds
Concepts in play
Redis LuaVirtual QueueKafkaInventory LockConcurrency