The interview problem

Practice prompt

Design room booking for 100,000 office rooms, averaging ten bookings per room per day. Support recurring meetings, free/busy search, concurrent requests and daylight-saving changes. Explain exactly which reservations are guaranteed, how edits affect a series, and what happens when an external calendar is unavailable.

Original system-design practice, not a reported company interview. Scale and examples are illustrative. Primary documentation retrieved September 27, 2026; page publication dates unstated; interview date not applicable.

1. Define the interval invariant

For rooms owned by this system, no two active occupancy intervals for the same tenant and room may overlap. Represent occupancy as half-open intervals [start, end), with finite bounds and end strictly after start. A 09:00–10:00 meeting can be followed by a 10:00–11:00 meeting. A 09:30–10:30 request conflicts with both.

Start with one room per booking and a 90-day hard-booking horizon. Display that horizon explicitly. A recurring rule can describe later dates, but those dates are not guaranteed until accepted by the authoritative booking service. If the product requires every occurrence of a year-long series to be guaranteed now, extend the supported transactional horizon rather than pretending a 90-day projection satisfies it.

Cleaning or setup buffers extend the occupied interval. Keep the displayed meeting interval and blocked occupancy interval separate so users understand why an apparently adjacent meeting conflicts. Attendee availability is another contract: sending an invitation does not reserve a person’s time across every external calendar.

2. Separate availability search from booking

client → free/busy projection → proposed time
                                  ↓
              authoritative room-booking transaction
                                  ↓
                    reservation + durable outbox
                                  ↓
           availability updates + invitation delivery

Cache free/busy intervals for quick searches, but treat them as suggestions. The write transaction enforces the invariant. A stale cache may suggest a slot that has just been booked; return a conflict with current alternatives rather than allowing the cache to authorize an overlapping reservation.

A relational database is a useful baseline. PostgreSQL supports timestamp ranges and exclusion constraints that combine a room key with an overlap operator. A uniqueness constraint on the whole interval is insufficient: two different intervals can still overlap. Include tenant and resource identity, reject null or invalid bounds, and apply the constraint to every state that blocks occupancy.

Keep all conflicting intervals for a room under one authoritative ownership boundary. Partitioning only by calendar date can split a meeting that crosses midnight and leave conflicting writes outside the same constraint. Read projections may be distributed widely; conflicting writes still need a common authority or an equivalent coordination protocol.

3. Trace a concurrent booking race

StepClient AClient B
Availability readSees room freeSees room free
Requested interval09:00–10:0009:30–10:30
Authoritative writeAttempts reservationAttempts reservation
OutcomeAt most one conflicting reservation commits; the other returns a conflict.

Checking for conflicts and then inserting without a database constraint or correct locking protocol permits both clients to pass the check. The invariant must survive interleaving writes, not just sequential tests. Do not assume which client wins.

Use an idempotency key scoped to the customer and operation, bound to the request payload. If A commits but its response is lost, retrying the same request returns the original reservation. Reusing that key for a different time is an error. Persist the result identity so the client can distinguish “booking failed” from “response not received.”

For the baseline, book immediately. If temporary holds are required later, they are blocking states too. Expiration must cause an authoritative state transition; the passage of wall-clock time does not itself remove an indexed row. Confirmation must check expiry and version atomically. A delayed expiration worker may temporarily reduce availability, but must not allow two confirmed reservations.

4. Preserve local recurrence intent

A weekly meeting at 09:00 in America/New_York is not a meeting every 168 elapsed hours at a fixed UTC time. Store the intended local start, named time zone and recurrence rule, then derive each occurrence’s UTC instant with the applicable time-zone rules.

Local Monday startUTC start
March 2, 2026 at 09:00 New York14:00
March 9, 2026 at 09:00 New York13:00
October 26, 2026 at 09:00 New York13:00
November 2, 2026 at 09:00 New York14:00

These conversions were checked with installed IANA time-zone data through Python’s zoneinfo. Adding 168 hours in UTC to the first March occurrence produces 14:00 UTC the following Monday, which is 10:00 local after the transition. The recurring meeting has drifted by an hour.

Some local times occur twice. In New York on November 1, 2026, 01:30 can mean 05:30 UTC or 06:30 UTC. For this product’s single-booking input, ask the user to choose the intended offset when ambiguous. Reject nonexistent local input with a useful explanation. For a recurring series, define and preview an explicit gap policy, such as skipping nonexistent starts. This is a product policy, not a claim that all calendar interchange formats use that rule.

Attaching a time-zone object to a local timestamp does not necessarily validate that the local time exists. Use transition-aware validation and test both ambiguous and nonexistent times. Keep import/export behavior behind a calendar adapter with conformance fixtures rather than silently imposing the first-party policy on every external event.

Choose a duration contract too. In this design, a 60-minute meeting lasts 60 elapsed minutes, so derive its end from its start instant. Its displayed wall-clock end may look unusual across a clock change. An all-day event is a local-date concept and should not automatically become exactly 24 elapsed hours.

5. Model series and occurrences separately

The series record contains a stable ID, tenant, organizer, local start, zone ID, recurrence rule, duration policy, exceptions, revision and confirmed-through date. Record the time-zone data version used for materialization. Each occurrence stores its original recurrence identity, actual UTC bounds, room, status and revision.

Use the original slot identity to address an exception. Moving one Wednesday meeting to Thursday changes its actual time but should not make it a new unrelated occurrence or accidentally modify the next Wednesday. Preserve cancellation tombstones and external event mappings long enough for retries and synchronization.

For a bounded series within the supported horizon, expand its occurrences and reserve them in one transaction: either all requested dates succeed or the operation returns conflict dates without changing the old state. Cap rule complexity, number of occurrences and transaction size. Partial acceptance must be an explicit product option with a visible result, not an accidental consequence of failing halfway through a loop.

For an indefinite rule, materialize a rolling window while showing which dates are confirmed and which are tentative. Extension workers use the same conflict checks as interactive writes and commit only against the current series revision, so a worker using an old rule cannot recreate canceled or edited occurrences. A failure to extend is a visible scheduling exception. Advance the confirmed-through date only when every intended occurrence up to that date has a resolved reservation or explicit exception; do not hide holes behind a later successful booking. An empty future cache must never be interpreted as a promise that every future occurrence is reserved.

6. Make edits and rule changes safe

An edit to one occurrence checks the expected revision and atomically replaces its occupied interval. If the new interval conflicts, the transaction rolls back and preserves the original booking. Deleting the old reservation first and asynchronously inserting the new one can lose the room without completing the edit.

An “all future occurrences” edit identifies its cut point by stable original recurrence identity, creates the next series revision and replaces affected materialized reservations within a bounded transaction. Concurrent stale edits fail version checks. Cancellations must not be undone by an older notification or synchronization response.

Time-zone rules themselves can change. Preserve the original local-time intent and the previously confirmed instants. Compare future occurrences under new rule data, detect conflicts and apply an explicit freeze-or-reschedule policy with visible changes. Do not silently move confirmed UTC intervals as a side effect of updating a library. Changing the display zone should merely change presentation; changing the series’ intended zone is a scheduling edit.

7. Keep external calendar state honest

Commit the room reservation and an outbox record together. Workers deliver invitations and projection changes with stable event IDs and revisions, using provider idempotency where supported and reconciling uncertain outcomes. The UI can show “room confirmed, invitation pending.” A provider outage should not force the local transaction to pretend that delivery succeeded.

External edits require a documented authority policy. If this system owns the room, an external meeting change becomes a request to update the authoritative reservation. If the external provider owns the room, local state alone cannot guarantee availability: keep the request pending until the provider’s authoritative acceptance mechanism confirms it. A cached free/busy response is not a distributed lock.

Free/busy access should reveal only the intervals the caller is allowed to see, not private meeting titles or attendee details. Apply tenant and room authorization to booking writes, and independently authorize richer event reads. Invitation recipients do not automatically gain access to every field in the organizer’s calendar.

8. Estimate storage and work

At 100,000 rooms, ten occurrences per room per day and a 90-day window, the system holds about 90 million occurrence rows. With an illustrative 200-byte logical metadata payload, that is 18 GB; three copies are 54 GB before indexes, database overhead, history and attachments.

One million new occurrences per day averages about 11.57 per second, but office-hour bursts and a single large recurring-series edit create different load patterns. Budget transaction limits and expansion work, not just average requests. Older history and cancellation records need separate retention accounting.

Index free/busy queries by authorized resource and bounded time window. Restrict query range and recurrence expansion so a malformed or extremely dense rule cannot monopolize CPU. Cache by relevant revision, and expose projection lag; cache invalidation cannot replace the write invariant.

9. Test the guarantees and failure boundaries

  • Concurrency: overlapping writes cannot both commit; adjacent half-open intervals can. Include cross-midnight and cleaning-buffer cases.
  • Recovery: a lost response followed by retry returns the same reservation; repeated outbox delivery does not resurrect canceled occurrences.
  • Series atomicity: a conflict on the last requested occurrence leaves earlier occurrences unchanged when the operation promises all-or-nothing behavior.
  • Time semantics: verify the spring/fall examples, both repeated-time offsets, nonexistent starts and elapsed-duration behavior.
  • Editing: moving one occurrence preserves its identity; stale edits fail; a rejected reschedule retains the original reservation.
  • Dependencies: stale availability, external outages and horizon-extension failures remain visible without violating local room guarantees.
  • Privacy: callers permitted to view free/busy cannot read private details or modify rooms outside their authorization.

Measure conflict responses, booking latency, projection lag, pending invitation age and series-extension failures separately. Fast search results do not prove correct booking behavior, and successful invitation delivery does not prove attendee availability.

Interview follow-ups

  • How do you reserve two rooms atomically? Use one transactional authority if feasible; otherwise define a coordinated reservation protocol and expose tentative state. Two independent successful writes are not an atomic operation.
  • Can the customer book every Monday forever? Store the intent, but state the finite confirmation horizon or implement a different guarantee with its full cost.
  • What happens when setup time changes? Recompute affected occupancy under versioned policy and detect new conflicts before applying it.
  • Can we store only UTC? UTC identifies occurrence instants, but it loses the local-time recurrence intent needed to derive future occurrences correctly.

Self-review rubric

A strong answer states the interval invariant, enforces it at commit and distinguishes search from reservation. It preserves local recurrence intent, stable occurrence identity and a truthful confirmation horizon. An excellent answer traces daylight-saving examples, handles atomic edits and synchronization failures, and explains why external free/busy data does not provide a cross-provider booking guarantee.

Sources and attribution

Page publication dates unstated; retrieved September 27, 2026. The prompt, architecture, workload estimates and scheduling examples are original practice. Product gap policies are stated explicitly and do not claim universal calendar-format conformance.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.