Design a scalable calendar system
Company: LinkedIn
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
Design a multi-tenant calendar system used by hundreds of millions of users. Specify core requirements (events, attendees, invitations, reminders, recurring rules, time zones, shared calendars, access control) and non-functional goals (low latency, high availability, strong consistency where needed, cost efficiency). Provide:
- APIs: Define REST/gRPC endpoints for creating/updating/deleting events, listing events in a time range, inviting/RSVP, searching by text/attendees/time, and managing calendars/shares. Include idempotency, pagination, filtering, and rate limiting.
- Data model: Propose relational schemas (Users, Calendars, Events, Attendees, RecurrenceRules, Exceptions) and detail keys, indexes, and constraints. Explain how you represent recurrence (RRULE + exceptions) and time zones. Discuss soft deletes and audit fields.
- SQL queries: Write representative queries, e.g., list all visible events for a user between [start, end], detect time conflicts for a candidate event, materialize a single series occurrence given RRULE + exceptions, and search by attendee and keyword with proper indexes.
- Scalability and storage: Choose partitioning keys (e.g., user or calendar), sharding strategy, and secondary indexes. Describe caching (read-through for event instances), search indexing, and background expansion of recurring instances vs. on-the-fly expansion.
- Consistency and concurrency: Handle concurrent edits, idempotent retries, distributed transactions vs. outbox pattern, and eventual consistency for search/notifications. Discuss disaster recovery, backups, and GDPR/retention.
- Notifications and integrations: Design reminder delivery, ICS import/export, and external calendar sync. Address abuse prevention and quota.
- Database choices: Compare when to use relational, document, or time-series databases for different features (e.g., metadata vs. change logs vs. analytics). Justify a primary store and any polyglot components.
Quick Answer: This question evaluates a candidate's ability to design a scalable, multi-tenant calendar platform, testing competencies in distributed systems architecture, API and data-model design for events/recurrence/time zones, access control and privacy boundaries, notification pipelines, and external integration.