System design · Recurrence, time zones, sync and reminders
How to design a calendar service
Store recurring events as time-zone-aware rules with bounded exceptions, then deliver changes and reminders asynchronously. The notification challenge covers delivery mechanics, not calendar recurrence or synchronization.
Updated · 5 min read
A teaching design of a system like Google, not Google's real architecture.
The short version
- A recurring event is a rule in a named time zone plus bounded exceptions. Expand it only inside the requested window.
- Commit each event version with an outbox record; queues deliver attendee updates and reminders from it.
- Push tells a device that something changed. The device then fetches changes from its sync cursor.
- An availability read does not stop a double booking. Exclusive rooms need a conditional reservation.
Clarifying questions to ask first
- Personal calendars, shared team calendars, or both? (Assume users own calendars and grant different permissions.)
- Do events repeat? (Assume recurrence rules and exceptions, but never an infinite occurrence list.)
- Does availability lookup prevent conflicts? (Assume lookup is supported, while exclusive room booking needs a reservation rule.)
- How quickly must attendees see changes? (Assume writes are immediate and push is a hint to fetch updates.)
- Reminders on several devices? (Assume yes, deduplicated per event, recipient and reminder type.)
Numbers that shape the design
These are assumptions, not Google Calendar traffic.
| Quantity | Assumption | Result |
|---|---|---|
| Event changes | 10M users × 4 a day | ≈ 463/s average, plan 4,630/s at 10× peak |
| Attendee updates | 30% of changes reach 3 attendees | ≈ 4,167 tasks/s at peak |
| Change log | 2 KB per change | ≈ 9.3 MB/s before replication and indexes |
| Reminder burst | 500,000 due within 5 minutes | ≈ 1,667 sends/s if evenly spread |
A popular reminder time is sharper than the even spread, so size the queue and add jitter. Hand dispatch to a notification system over a message queue.
API
POST /calendars/{calendarId}/events
{ start, end, timeZone, recurrence, attendees }
PATCH /calendars/{calendarId}/events/{eventId}
If-Match: <event-version>
GET /calendars/{calendarId}/events?from=...&to=...&syncToken=...
GET /calendars/{calendarId}/freeBusy?from=...&to=...If-Match stops one device silently overwriting another's edit; a stale device gets a conflict to resolve. A range query must say whether it returns series masters, expanded instances or both. Every endpoint checks calendar access: an event ID is not an authorisation token.
Data model
A series master holds local start time, named zone, duration and rule; a one-time event has no rule. Edited or cancelled instances are exceptions keyed by series and occurrence start. Attendee responses get their own rows.
- A monotonically increasing version and an append-only change record per event, for sync.
- Calendar ACL entries with owner, editor and reader roles.
- Reminders keyed by event version, recipient and offset.
- A rebuildable time-range index for listing and availability.
Recurrence and time zones
A weekly 09:00 meeting stays at 09:00 local time after a daylight-saving change, even though its UTC instant moves. So store the zone identifier and rule, compute instances for the requested window, capped by a result count. Decide what happens when a local time is skipped or repeated at a clock change. Never infer the event's zone from the viewer's device.
Cached occurrences carry the event version, so a rule edit invalidates them. The reminder scheduler resolves the due instant from the zone and rule, then checks the version before sending so edits supersede pending reminders.
Availability and double booking
Availability reads find intervals overlapping a range through the calendar-and-time index, still checking each calendar's permissions. A caller who can't read details gets free/busy only.
Two users can both see a free slot and both book it. Personal events may overlap by product rule. Exclusive booking needs a reservation record with a conditional write or another serialisation point.
Push, sync and reminders
Google's Calendar API docs (https://developers.google.com/workspace/calendar/api/guides/push) say push messages carry no changed-resource body, channels expire, and messages can be dropped. So push is a hint. Each device keeps a cursor and fetches changes after it; an invalid or too-old cursor gets a reset response and a fresh snapshot. Renew channels before expiry.
The outbox means a commit can't lose its notification intent. Search and sync read the change log instead of polling event rows.
High-level design
The API authenticates, checks permissions, validates and commits a new version with an outbox record in one transaction. A publisher sends attendee updates and reminders to queues. The query service reads the time-range index and expands recurrence only inside the window.
Common traps
- Storing only UTC, which loses the intended local time of a recurring event.
- Expanding a series into permanent rows, or expanding the whole series on every read. Both are unbounded work.
- Treating push as the update itself. It is a hint, and a dropped one leaves the device stale until it syncs.
- Assuming an availability read prevents a concurrent booking.
- Letting shared start times spike the reminder queue. Spread sends across an allowed window where the product permits.
- Partitioning by calendar and forgetting very large shared calendars, which become hot partitions with big fan-out.
Follow-up questions interviewers ask
- "How is a weekly meeting stored across daylight-saving changes?" Local time, named zone and recurrence rule.
- "What if a push message is lost?" The device recovers from its sync cursor and the durable change log.
- "Can two users book one room at once?" Not if the reservation is a conditional write; a free/busy read is not enough.
- "How do old reminders get cancelled after an edit?" The event version is part of the task identity.
- "A consumer fell behind. Now what?" Rebuild its index from the change log.
Frequently asked questions
Should a recurring event store every occurrence?
+
Usually not indefinitely. Store a rule and bounded exceptions, then expand the requested range. Cache a limited window only when measurements justify it.
How should a calendar handle daylight-saving changes?
+
Store a named time zone and local recurrence rule. Resolve each occurrence using zone rules and define handling for nonexistent or repeated local times.
Are push notifications enough to keep devices in sync?
+
No. The cited Calendar API docs say messages can be dropped and omit the changed resource. Fetch changes using a sync cursor and reconcile periodically.
Does the notification challenge test calendar consistency?
+
No. The notification challenge covers queued dispatch and rate limits; recurrence, permissions, sync cursors and conflict resolution are outside its scope.