Skip to content
Preptima
hardDesignScenarioMidSeniorStaff

Two customers try to buy the last item at the same time. How do you handle inventory?

6 min readUpdated 2026-08-15

Answer

Short answer

Treat availability as a claim you grant, not a number you read: fold the check and the decrement into one conditional write, hold the winner's claim as a reservation that expires, and choose deliberately how much overselling you accept, because the warehouse and not the database is the real source of truth.

Was this answer helpful?

Likely follow-ups

  • A single hot SKU is taking thousands of concurrent purchase attempts. Where does your design break first?
  • Cycle counting finds nine units where the system says twelve. What do you do with the three orders already promised?
  • How would you support backorders and pre-orders in the same model?
  • A customer holds an item in a reservation for twenty minutes and abandons. What did that cost you, and how do you measure it?

Related questions

Further reading