Courses / System Design Interview / Chapter 42
Module 9 · Design Problems IV: Platforms and Money · Chapter 42 of 49
Design a Calendar Service like Google Calendar
Builds on Back-of-the-Envelope Estimates, Databases: Choosing, Replicating and Partitioning, Distributed Caches, Distributed Message Queues and Distributed Task Schedulers. Next up: Design a Metrics Monitoring and Alerting System.
Part 1 · Requirements and estimates
What a calendar must do
A calendar looks like a table of boxes, but every box is a promise about time: a meeting at 10:00 must still be at 10:00 on the day, wherever people sit. Calendars are read all day and written rarely, and they must wake people up at the right minute.
The functional requirements are these. A user creates, edits and deletes events, each with a start, an end, a time zone, a title, a place and a list of guests. An event can repeat, for example every Monday and Wednesday, and a single repeat can be cancelled or moved without touching the rest. Guests receive an invitation and answer yes, no or maybe; the organiser sees the answers. A user views a day, a week or a month, on several devices that stay in step, including a phone that was offline for a day. To schedule a meeting, a user looks at when other people are free, without seeing what they are busy with. Reminders arrive before an event by push or email. We leave out video links, room booking and attachments.
The non-functional requirements begin with correctness of time. An event that moves by an hour twice a year is a defect users notice at once, so time zones and daylight saving have to be right, and the lesson on time zones is where that is settled. Reads dominate: people open the calendar far more often than they change it, and they expect a week to appear in a fraction of a second. Reminders must go out on time, within seconds of the minute people chose. Edits must reach every device quickly and must never be lost. And privacy matters: sharing availability should reveal less than sharing the calendar itself.