KatInterview

Build a Time-Zone-Safe Scheduling Backend for Recurring Events

System DesignModel answer
MediumModel answerSystem Designsystem-designcalendartime-zones

Last updated

Design a scheduling service where users in different time zones create, edit and query one-off and repeating events, with correct behavior across daylight saving changes.

You are asked to design the backend for a scheduling product used by people all over the world. Users can have events that happen once or repeat, and they view their agenda in whatever time zone they are currently in.

The service must support:

  • Creating, modifying, removing and reading events.
  • Single events as well as repeating ones (daily, weekly, monthly, with an end date or count).
  • Fetching one user's agenda for an arbitrary time window.
  • Keeping events correct when the people involved live in different zones.
  • Behaving sensibly when clocks shift for daylight saving time (DST).

In your answer, cover:

  1. Assumptions about scale and the main non-functional goals.
  2. The API surface, including how a single occurrence of a repeating event is addressed and edited.
  3. What you persist for each kind of event, and how repeating events are represented.
  4. Time zone handling, with particular attention to a repeating event whose organizer is in a zone that observes DST. What do the organizer and a remote attendee each see before and after a clock change? What happens to an occurrence that lands in a skipped or repeated local hour?
  5. Storage layout, partitioning, and whether occurrences are computed at read time, precomputed, or both.
  6. How you detect scheduling conflicts for people and for shared resources such as meeting rooms.
  7. Scaling, caching, and the consistency model, including concurrent edits.

Hints

Hint 1

Separate what the user meant from the instant it maps to. A repeating 'every Monday at 9:00 in the organizer's zone' is a local wall-clock rule plus a zone ID, not a fixed UTC time.

Hint 2

Think about the three kinds of time values: absolute instants (one-off events), local time plus zone (repeating events), and floating dates (all-day events). Never store a bare numeric offset in place of a zone ID.

Hint 3

Infinite series cannot be fully precomputed, but pure on-read expansion is costly at high read volume. Consider a rolling materialized window per attendee, sharded by user, with fallback expansion outside it.

Hint 4

Treat people conflicts as warnings and room conflicts as hard constraints that need a transactional or uniqueness guarantee on the room's shard.