System design · Patterns: the problems hiding inside most prompts

Contention: two buyers, one seat

Whenever two users can try to take the same scarce thing at the same time, the design needs an explicit answer to who wins, and the answer is almost always an atomic conditional write in one database rather than a distributed lock.

24 min read Full lesson in the app Patterns: conditional write, optimistic concurrency, fencing token, reservation with expiry

What you'll be able to do

Before this: picking-a-datastore, replication-and-consistency

Log in to read the rest of this lesson

Whenever two users can try to take the same scarce thing at the same time, the design needs an explicit answer to who wins, and the answer is almost always an atomic conditional write in one database rather than a distributed lock. This walkthrough runs about 24 minutes, with runnable code you can edit and re-run as you read. A new account gets 7 days of Pro free, no card required.

Log in to continue

The first module of every track is free to read on the web: see what's open in System design.