KatInterview

Scheduling Collision Detection for a Shared Calendar Service

System DesignModel answer
MediumModel answerSystem Designsystem-designcalendarconflict-detection

Last updated

Design the backend that detects and handles scheduling collisions when users create or edit events, covering recurrence, attendees, privacy, time zones, and concurrent edits at massive scale.

You are designing the event and collision-handling backend of a calendar product used by hundreds of millions of people.

Users create, edit, and delete events. An event can include a list of attendees, start and end times, a time zone, a recurrence rule, reminders, a visibility level, a location, and a video-call link.

Your focus is what happens when a new or modified event collides with something already on someone's calendar. Cover the data model, the path a collision check takes, and how the design behaves under heavy load.

Assumptions to state and justify

Pick numbers of a sensible order of magnitude. A reasonable starting point:

  • Around $10^8$ active users, each with many events. A single busy calendar (a meeting room, an executive) may hold thousands of events per quarter.
  • Traffic is dominated by reads: availability lookups and collision checks far outnumber writes.
  • A collision check during create or update should feel interactive, with a target of tens of milliseconds for the common case of an organizer plus a few attendees.
  • Events must never be silently lost, and reads must be highly available.
  • The collision policy is configurable: reject, warn (user must confirm), or allow override. Consumer calendars typically allow double-booking with a warning.
  • Only events marked busy, tentative, or out-of-office affect availability. Events marked free never cause a collision.

Questions you should consider asking

  • Is double-booking permitted with a warning, or blocked outright? Does the answer differ for organizers and invitees?
  • With several attendees, does a collision for any one of them block the event, only required attendees, or only the organizer?
  • How far ahead must checks on recurring events look, and can a series be unbounded?
  • What do users see of calendars they do not own: full details, busy-only, or nothing?
  • Should tentative, free, and out-of-office events count as hard collisions, soft collisions, or be ignored?
  • Is interoperability with external or federated calendars required?

What to deliver

Walk through requirements, data model, the exact overlap rule, indexing, recurrence handling, the create/update flow, concurrency control, privacy, time-zone correctness, consistency between stores, and the user-facing experience when a collision is found.

Hints

Hint 1

Separate the canonical event record from a derived, query-optimized availability index. The index only needs calendar id, time range, busy status, and a pointer back to the event.

Hint 2

Define overlap precisely with half-open intervals: two events collide when A.start < B.end and B.start < A.end. That makes back-to-back meetings non-colliding. Then decide how free, tentative, out-of-office, and all-day events are treated.

Hint 3

Do not expand an unbounded recurrence forever. Store the rule, materialize a rolling window ahead of time, expand on demand beyond it, and handle per-occurrence exceptions. For concurrent edits, compare optimistic versioning against a short per-calendar lock.