← All challenges
CHALLENGE #001

Two Users, One Product: How Do You Prevent Overselling?

Backend DevelopmentIntermediateOpen

An online store has one unit left when two customers click Buy at nearly the same moment. A read-then-write implementation can confirm both orders, especially when requests reach separate application servers.

The scenario

Compare transactions, row locks, atomic stock updates, reservations, and distributed coordination. Explain what happens when payment succeeds but inventory confirmation fails, and how you would make the workflow observable and recoverable.

The question

How would your design behave under retries, replicas, slow payment providers, and a database failover? Which invariant must never be violated?

The official solution is not published yet.Think it through with the community first.

Community discussion

0 contributions

Be the first to share your reasoning.

Share your approach

Use your real display name. Guest emails are used for verification and never shown publicly.
Chat with us