How to design Google Calendar
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
- The problem
- Clarifying questions
- The requirements menu
- Non-functional requirements
- Estimates
- Core entities
- The API
- The high-level design
- What breaks first
- The deep dives
- Entity fields
- Repeating events and time zones
- Invites across calendars
- Finding a free slot
- Reminders on time
- Variants
- What each level is expected to show
- The 30-second answer
- Quiz
The problem
Google Calendar keeps people's events, repeats them on a rule, puts one meeting on many calendars in many time zones, answers who is free when, and fires reminders. People open their calendars far more often than they change them, and a weekly meeting with no end date has no last occurrence to write, so the answer turns on storing a series as one rule plus its exceptions in the organizer's own time zone, and moving the heavy work (expanding occurrences, fanning an edit out to hundreds of calendars, finding the reminders due this minute) off the read path or ahead of time.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
How many people use it, and how do reads compare with writes? | The mix decides where to spend effort. If people mostly look at their week, the read path (expanding series, drawing a view) gets the caching and the indexes, and writes can afford extra work such as updating a busy index. | About 100 million users, mostly reading their calendars. No request rate is given, so state an assumption out loud and move on. |
Can a repeating event run with no end date, and can one occurrence be changed on its own? | An endless series rules out writing a row per occurrence, and a changed single occurrence means the design needs exceptions, not just a rule. | Yes to both. A weekly meeting can repeat with no end, and someone can move one Thursday or change this and all following occurrences. |
How many guests can one event have, and how many calendars does one availability check span? | Fan-out size decides whether an edit can update attendee calendars inside the request or must go through a queue, and the free/busy cap sizes the work of one availability request. | Up to 100,000 guests on one event, though a typical edit reaches hundreds. One free/busy check covers at most 50 calendars. |
Are attendees spread across time zones, and must times survive daylight saving changes? | If yes, the design stores a named time zone with each event rather than a UTC instant or a fixed offset, and expands a series in that zone. | Yes. An attendee abroad must see the right local time, including in the week the clocks change in either country. |
How exact must a reminder be: on the minute, and at most once? | On time and once pushes the design toward reminders stored by their due minute and a per-occurrence id that lets the notification side drop repeats. | A reminder fires on time and once. A duplicate or a reminder for a canceled occurrence counts as a bug. |
Can people outside the system be invited? | An outside guest has no calendar here, so their path is email, which changes what the fan-out worker does per attendee. | Yes. Outside guests get the invite and any change by email. |
Are rooms, search over events and sync with other calendar products in scope? | Each is a system of its own; naming them as out of scope keeps the round on events, series, invites, availability and reminders. | No, all three are out of scope for this round. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
About 100 million users, with far more reads than writes (Google report) | Partition events by calendar so a week view is one range read on one partition, and spend the design effort on the read path: cached expansions for busy calendars, a busy index for availability. Writes can afford extra work, such as updating that index. |
Conflict and free/busy checks answer fast enough to feel interactive | An availability request across up to 50 calendars shouldn't expand each series of each person on the spot. Keep busy intervals for the coming weeks ready per calendar, so the request reads and merges intervals instead of computing them. |
Times stay right across time zones and daylight saving changes | Store each event's local start and end with a named time zone (a zone name such as America/Los_Angeles, not a fixed offset), expand a series in that zone, and convert per viewer at read time. Keep the zone rules in a database you can update when a government changes them. |
A reminder fires on time, and only once | Reminders are stored by the minute they fall due, not found by scanning events. Delivery may repeat after a crash, so each send carries a key built from the reminder and its occurrence and the notification side drops a second copy; a worker also rechecks the event before sending in case it moved. |
An organizer’s change reaches every attendee’s calendar | One copy of the event is the truth, and it lives on the organizer's calendar. A change is fanned out through a queue to each attendee's entry with idempotent writes, so a retry after a crash does no harm, and devices catch up with an incremental sync. |
Estimates
| Quantity | Working | Result | What it sizes |
|---|---|---|---|
Rows if a weekly series were written out one row per occurrence | 52 occurrences a year per weekly series; the interviewer's assumption is about 100 million people each keep one such series: 100 million × 52 ≈ 5.2 billion rows a year, and about 52 billion over ten years, with no end date to stop the growth | About 5.2 billion new rows a year from weekly series | The storage and write cost of writing occurrences out, which is why a series is stored once as a rule and expanded for the range a view asks for. |
Attendee writes for one edit of the largest allowed event | One event may have up to 100,000 guests, so one time change means 100,000 attendee-entry updates. As an example only, if each write took about 1 ms and they ran one after another inside the request, the request would wait about 100 seconds; a typical edit reaching hundreds of attendees would still wait hundreds of milliseconds | Up to 100,000 writes per edit, about 100 seconds if done inline one by one under that example assumption | Why the fan-out leaves the request: the organizer's save writes one row and enqueues one message, and workers update attendee entries behind it. |
Reminders due in the busiest minute | An example assumption, not a target: one in ten of the 100 million users has a Monday 9 AM meeting with a ten-minute reminder, so 10 million reminders fall due in the 8:50 minute; spread across the 60 seconds of that minute, that is about 167,000 sends a second | About 10 million reminders in one minute, roughly 167,000 a second averaged over it | The number of partitions the due-reminder buckets need and the send rate the notification service must take; a scan of the events table each minute is out of the question at this rate. |
Intervals one availability request at the cap must merge | At most 50 calendars per query over a one-week window; as an example assumption, 30 busy blocks per calendar per week gives 50 × 30 = 1,500 intervals to collect, sort and merge, after expanding each series that touches the week | About 1,500 intervals per request at the cap, each from an expansion if nothing is precomputed | The work a free/busy request does when it expands on the spot, and what a per-calendar busy index saves. |
Core entities
| Entity | What it holds |
|---|---|
Calendar | One per person or team: who owns it, its default time zone, and who may see what. |
Event | A single meeting or the head of a series; the organizer's calendar holds the one copy that counts. |
Exception | One occurrence of a series that was moved, changed or canceled. |
Attendee | A person's entry for an event: their own calendar's view of it plus their answer. |
Reminder | What a person asked to be told, how long before, and by which method. |
Due reminder | A reminder resolved to the minute it fires for one occurrence, ready for a worker to claim. |
Busy interval | A precomputed busy block on one calendar, kept for the coming weeks so availability reads don't expand series. |
The API
| Endpoint | Notes |
|---|---|
| Start and end are wall-clock times in |
| One range scan on the calendar's partition for single events, attendee entries and series heads, then the expander produces occurrences inside the window, applies exceptions and converts each to the viewer's zone. Busy calendars answer from a cached expansion of the window. |
|
|
| In this design, the response is written on the attendee's own entry and then copied back to the organizer's attendee list through the same fan-out path, so the organizer's view of who is coming stays current; the response is the one attendee change that flows back, and the shared time is not touched, so an attendee can't move a meeting for everyone. |
| Checks that the caller may see at least free/busy on each calendar, rejects more than 50 calendars, and reads the busy index for the window. Returns intervals with no titles, in UTC or a zone the caller names; the client intersects the gaps across people. |
The high-level design
Step 1 of 4
One service over events partitioned by calendar
Start with the read path, since that is where the load is. Web and phone clients call an event service, which reads and writes one store of events partitioned by calendar id, so a week view is one range scan on one partition. A repeating event is one row holding its rule and its time zone, plus a small set of exception rows for moved or canceled occurrences; the service expands the rule into occurrences for the window the client asked for, applies the exceptions and converts each occurrence to the viewer's zone. Nothing is written per occurrence, so a series with no end date costs the same as a single event to store.
What breaks first
The deep dives
Repeating events and time zones. A weekly 9 AM meeting repeats with no end date, someone moves one Thursday, and an attendee in another country opens their week view in the week their clocks change. What is stored, and how does the view get drawn?
A concept that helps here: Recurrence rules and time zones
A concept that helps here: Core entities and the data modelA concept that helps here: Caching strategiesInvites across calendars. An organizer invites hundreds of people to a weekly meeting and then moves it by an hour. How does the new time reach each attendee's calendar and phone, what do attendees see in the meantime, and what happens if the updater fails halfway?
Finding a free slot. Someone needs a free hour next week for eight people in four time zones, several of whom keep long repeating series. How does the request become a list of open hours, what does it cost, and what if one of the eight books something while the list is on screen?
Reminders on time. Millions of meetings start at 9 AM on Monday, each with a reminder ten minutes before. How does each reminder fire at 8:50, once, even when a sender crashes mid-minute, and what stops one firing for an occurrence that was moved or canceled?
Concepts this guide uses
Sources
- Google Calendar API: recurring events
- Google Calendar API: synchronize resources efficiently
- Google Calendar API: Freebusy query
- Google Calendar API: reminders and notifications
- Google Calendar API: calendar sharing
- Google Calendar API: calendars and events
- Google Calendar API: invite users to an event
- Google Workspace Updates: improvements for scheduling large scale meetings on the web
- IETF RFC 5545: Internet Calendaring and Scheduling Core Object Specification (iCalendar)
- IANA: Time zone and daylight saving time data (tz-link)
- Wikipedia: tz database
- System Design Academy: Design Google Calendar