Design a Task Scheduler

Quick Overview

Design a distributed job scheduling system. Cover job prioritization, cron-like recurring tasks, failure handling and retries, resource allocation, and ensuring exactly-once execution semantics.

Google
System Design
Software Engineer
Google
Software Engineer
System Design Round
System Design
Medium

0


Design a distributed job scheduling system. Cover job prioritization, cron-like recurring tasks, failure handling and retries, resource allocation, and ensuring exactly-once execution semantics.

Google runs enormous fleets of batch and recurring jobs, so a distributed scheduler is a natural system design question. The interviewer checks how you handle prioritization, cron scheduling, retries, and above all how you avoid running a job twice when schedulers or workers fail.

What the Interviewer Expects
  • Define requirements: one-off and cron jobs, priorities, retries, and resource needs
  • Estimate job volume and concurrent worker demand
  • Design a durable job store, a scheduler that claims due jobs, and a worker pool
  • Use leases or fencing tokens with idempotent jobs for effectively exactly-once execution
  • Explain retry with backoff, dead-letter handling, and priority queues
  • Discuss leader election and high availability of the scheduler
Key Topics to Cover
Job scheduling
Exactly-once semantics
Leases and fencing
Retries and backoff
Leader election
Priority queues
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • What happens if a worker finishes a job but crashes before reporting success?
  • How do you avoid all midnight cron jobs firing at the exact same second?
  • How would you prevent low-priority jobs from starving forever?
  • How would you scale the scheduler itself beyond a single leader?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Functional Requirements:
    • Job submission: Users should be able to submit jobs with parameters such as priority, schedule (cron-like), and resource requirements.
    • Job prioritization: The sy...
Capacity Estimation

Assuming Google has a user base that submits a large number of jobs:

  • Daily Job Estimates:
    • If we estimate 10 million jobs submitted per day, that’s approximately 115 jobs per second.
  • **Job...

Submit Your Answer
Markdown supported