Design a Reminder Service
Understanding the Problem
⏰ What is a reminder service? A reminder service lets users say "remind me to call the dentist tomorrow at 9 AM" or "remind me to take my medication every day at 8 PM," and then sends them a notification at that time. It's a scheduler with an unusual shape: hundreds of millions of tiny timers, each owned by a person, almost all of them far in the future, and a lot of them due at exactly the same minute.
The requirement that makes this interesting is usually stated as "each reminder fires exactly once, within 5 minutes of its due time." Both halves matter. "Within 5 minutes" sets how late we can be, and it's generous enough to change the design. "Exactly once" means no missed reminders and no duplicates, which in a distributed system really means at-least-once firing with deduplication. We'll come back to both throughout.
Functional Requirements
Core Requirements
- Users should be able to create a one-time reminder for a specific date and time, in their time zone.
- Users should be able to create recurring reminders (daily, weekly on certain days, monthly, and so on).
- Users should receive each reminder as a notification (push, with email as a fallback) within 5 minutes of its due time, exactly once.
- Users should be able to list, edit, delete and snooze reminders.
Below the line (out of scope)
- Location-based reminders ("when I get home").
- Shared reminders and assigning reminders to others.
- Natural-language parsing of "next Tuesday after lunch" (the client sends a structured time).
Non-Functional Requirements
Ask about scale. We'll assume 100 million users, 1 billion active reminders (most of them recurring), and 200 million reminders firing per day.
Core Requirements
- Every reminder should fire within 5 minutes of its due time.
- Each occurrence of a reminder should be delivered exactly once: never missed, never duplicated.
- The system should be durable: a reminder accepted is never lost, even if servers fail at its due time.
- Firing should handle sharp peaks: many reminders are due at round times like 9:00 AM.
- Creating and editing reminders should be fast (under 200 ms) and highly available.
Below the line (out of scope)
- Second-level precision. Minute-level is plenty, and the 5-minute window lets us smooth load.
- Guaranteeing the phone shows it. Once the push provider accepts it, delivery to the device is best effort.
Back-of-the-envelope. 200M fires/day ÷ 86,400 ≈ 2,300 fires per second on average. The average is misleading. People pick round times, and they pick them in their local time zone, so the top of each hour in a populous time zone is a spike. If 5% of a day's reminders land in the minute after 9:00 AM in a large region, that's 10M reminders due in one minute, about 170k/s for that minute. Writes are light by comparison: say 20M creates and edits a day, ~230/s.
Storage: 1B reminders × ~300 bytes (user, text, schedule, metadata) ≈ 300 GB, easily handled by a sharded database. The size of the data isn't the problem; the problem is finding the right 10M rows at the right minute, and firing each exactly once.
The 5-minute window is a gift. It means we don't need a precise timer per reminder. We can work in coarse time buckets, prefetch due work a little early, and spread a 9:00 spike across 9:00-9:04 without breaking the requirement. Say this out loud; it's the insight the question is built around.