Design a Leader-Elected Distributed Cron Service With Missed-Run Handling
Last updated: November 29, 2026
Quick Overview
Design a cron service like Cloud Scheduler that runs millions of user-defined schedules ("every 5 minutes", "daily at 02:00 America/New_York") reliably, firing each job once per scheduled time even when machines fail.
0
0
0 solved
Design a cron service like Cloud Scheduler that runs millions of user-defined schedules ("every 5 minutes", "daily at 02:00 America/New_York") reliably, firing each job once per scheduled time even when machines fail.
Google has published how its internal distributed cron uses Paxos-backed state to avoid double launches, so interviewers like probing at-most-once versus at-least-once launch semantics. The focus is on failover correctness, time zones, and what happens to runs that were missed during an outage.
What the Interviewer Expects
- Store schedules and launch state in a replicated, strongly consistent store
- Explain how leadership or shard ownership prevents double firing
- Define launch semantics and require idempotent targets
- Handle time zones and daylight saving transitions correctly
- Specify policy for missed runs after downtime
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- What happens if the leader crashes after sending the HTTP call but before recording it?
- How do you shard millions of schedules across schedulers?
- How do you handle a job whose previous run is still executing?
- How does a 02:30 daily job behave on a DST spring-forward day?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Users create jobs with a cron expression, time zone, target (HTTP endpoint, Pub/Sub topic), retry policy.
- Each scheduled time triggers at most one successful launch, with retries on target failure...
High-Level Design
- Job store: Spanner table: job_id, schedule, tz, target, next_fire_time, last_launch_id, state.
- Scheduler shards: job IDs hashed to shards; each shard owned by one scheduler task holding a ...