When asked to design a reservation service, resist the urge to start with a diagram full of infrastructure. First, find the rule your design must preserve when two requests arrive at the same time. In this example, a confirmed reservation must never take capacity below zero. The design is illustrative, not a claim about a particular interview or a complete blueprint for production.

Agree on a problem small enough to finish

1. What should you clarify before drawing anything?

Ask what is being reserved, whether inventory is pooled or assigned to specific seats, and what counts as confirmation. For this exercise, assume a user reserves one unit in a pooled time slot. The service lists availability and confirms reservations immediately. Leave payments, cancellations, hold expiration, and multi-region writes out of scope initially. Ask whether availability shown to users can be a few seconds stale. A slightly stale list is a different risk from confirming more reservations than the slot can accommodate.

Say the invariant out loud: for each slot, confirmed reservations must not exceed its capacity. Then walk through the user-facing result when availability is shown but someone else takes the last unit first. A “sold out” response is acceptable; quietly confirming both requests is not.

2. Which numbers would change your first design?

Estimate the write rate, the read-to-write ratio, and how concentrated traffic is. As a round-number assumption, 720,000 attempts per day averages about 8.3 per second. A launch minute with 12,000 attempts averages 200 per second over that minute. Neither number is the maximum instantaneous load, and neither reveals how many attempts hit the same slot. One hundred concurrent requests for one slot stress a very different path from one hundred requests for independent slots. Use the estimate to decide what to test, not to assert a database throughput limit.

Draw the baseline and trace a failure

3. How do you prevent two users from claiming the last unit?

Start with an API backed by a relational database. Keep one inventory row per slot and a separate table for confirmed reservations. In one transaction, decrement remaining inventory only if it is positive, then insert the reservation if the decrement changed a row. If inserting fails, roll back the decrement. In PostgreSQL at Read Committed isolation, a concurrent updater waits on a row being modified and rechecks the update condition on the newly committed version of that row. A separate read of the count followed by an unconditional write does not provide that protection.

UPDATE slots
SET remaining = remaining - 1
WHERE id = $1 AND remaining > 0
RETURNING id;

This is only the inventory statement, not the whole transaction. Add a nonnegative constraint to the row as a backstop, not as a substitute for writing the inventory and reservation atomically. Explain that all inventory-changing paths have to respect the same invariant. If the product later assigns individual seats, a unique constraint on slot and seat can enforce a different rule; pooled capacity and individual seats are not interchangeable.

4. What if the database commits, but the client never receives the response?

A timeout tells the client it did not receive confirmation, not that the write failed. Let the client send an idempotency key scoped to its identity. Store the key, request meaning, and successful result alongside the reservation in the same transaction. Enforce uniqueness so concurrent retries cannot both own the same key. If a retry reaches a committed result, return the same reservation rather than decrementing capacity again. Reusing the key for a different slot should be rejected. Say how long clients may rely on retained keys; an undocumented expiration can turn a late retry into a new reservation.

5. What can you cache or queue without breaking the promise?

Cache the availability read if stale numbers are acceptable, but use the authoritative database write to decide whether to confirm. Partitioning by slot can spread load across independent slots; it does not solve contention inside a single hot slot. Queueing can smooth work if the user accepts a pending state, but it does not remove contention or justify presenting acceptance into the queue as a confirmed reservation. A first step for the synchronous baseline is to measure lock wait and tail latency under realistic traffic. Break out sold-out responses from system errors so normal scarcity does not hide an outage or inflate an error metric.

Rehearse with a clock

  • Spend two minutes naming the actors, exclusions, and the invariant. Draw the write path before adding any cache.
  • Walk through two users and one remaining slot, then a successful commit followed by a lost response.
  • Change one requirement: allow reservation holds, or make one popular slot receive most of the traffic. Name the first part of the design you would revise and what you would measure.
  • Finish by summarizing what the baseline guarantees, what it leaves out, and which assumption you would validate first.

See how to choose the right depth for a senior interview, then try Mentaro's free practice demo to rehearse answering a sample prompt before reading its explanation.

Sources