Design a Distributed Job Scheduler

Distributed job scheduler inspired by Airflow, Kubernetes CronJobs and the distributed cron described in Google's SRE book: jobs saved with their next fire time, partitioned schedulers holding leases and firing from in-memory timer wheels, exactly-once claims with a conditional insert, an executor fleet behind a dispatch queue, heartbeats, retries with backoff, dead letters, and a run status cache. A teaching design.

Functional requirements

  • Users can create, update, pause and delete jobs with a cron schedule.
  • Each job runs at its scheduled time.
  • A scheduled run executes once, never twice, even with several schedulers running.
  • Failed runs are retried with backoff, and owners are alerted when retries run out.
  • Users can see each job's run history and status.

Non-functional requirements

  • Runs start within a few seconds of their due time.
  • Scale: 10M registered jobs, 2K API requests/s at peak, large bursts at the top of every hour.
  • No run is skipped because a scheduler or executor failed.
  • Availability: 99.95% for scheduling.
  • Run status lookups: p99 < 100ms.

How the design evolves

Stage 1: One Cron Server

See why a single crontab box misses runs and can't grow.

What was missing: Nothing yet.

Why that's risky: If the server is down at 02:00, the 02:00 runs never happen. Long jobs pile up on one machine, and a burst at the top of the hour overloads it. Job code shares the box with the scheduler.

What gets added: One server that keeps jobs in a table and executes every due job itself, once a minute.

Trade-offs: This is how cron works on one machine. It's fine for a handful of jobs, not for a company's worth.

Stage 2: Job API, a Scheduler and an Executor Fleet

Separate deciding when a job is due from executing it.

What was missing: One machine decided when jobs were due and also executed them.

Why that's risky: There is one scheduler. Run two for safety and both fire every job, so jobs execute twice. Nothing retries a failed run.

What gets added: A job API that saves jobs with their next fire time, a scheduler that finds due jobs and puts each run on a dispatch queue, executor workers that call the job's target, and a runs table for history.

Trade-offs: A run starts a moment after its due time because it passes through a queue. Scheduled jobs almost never need sub-second precision.

Stage 3: Leases, Timer Wheels and Exactly-Once Claims

Run several schedulers without ever firing a job twice.

What was missing: Two schedulers meant every job fired twice.

Why that's risky: A failed run is simply marked failed, and a run whose executor hangs looks like it's still going forever.

What gets added: The jobs table is split into partitions, and each scheduler holds a renewable lease on some of them. A scheduler loads the next few minutes of due jobs into an in-memory timer wheel, and claims each run with a conditional insert unique on (job, due time), so even an overlapping scheduler can't claim the same run.

Trade-offs: Leases take a few seconds to expire, so if a scheduler dies, its jobs can start a few seconds late.

Stage 4: Retries, Heartbeats and Dead Letters

Recover failed and stuck runs automatically, and tell owners about the ones that can't be recovered.

What was missing: Failed runs stayed failed, and a hung executor held its run forever.

Why that's risky: Dashboards and CI pipelines poll run status from the database every few seconds, and there is one load balancer.

What gets added: Executors send heartbeats while a run is going, and a run without one is treated as failed. Failed runs go to a retry queue, and a retry worker executes them again after an exponential backoff. Runs that use up their retries land on a dead-letter list, and the owner is alerted.

Trade-offs: Retries mean a job may run more than once after a partial failure, so job targets should be idempotent. The run id is passed to them for that.

Stage 5: Status Cache, Limits, Redundancy and Monitoring

Serve status polling cheaply, and spot schedule lag before owners do.

What was missing: Status polling read the database, one team could register millions of jobs, and nobody watched schedule lag.

Why that's risky: Remaining risk is low. A huge burst at the top of the hour still queues behind the executors, but no run is skipped.

What gets added: A run status cache written by executors, a rate limiter with per-team quotas, a second load balancer, a replicated runs database, more executors, and monitoring of schedule lag (due time against start time), failure rate and dead letters.

Trade-offs: Jobs due at :00 may start a few seconds late during the hourly burst. Spreading start times (jitter) is offered to owners who can accept it.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Send feedback
Phase
Build & Stress Test
Phase 01: Thinking in Systems
Upcoming

Components

User
CDN
Load Balancer
Server
Cache
Database
Blob Storage
Search Index
Queue
Worker
Rate Limiter
Service
API Gateway
Reverse Proxy
WebSocket Server
Third-party API

Inspector

Notes
Use clear names so your design intent is easy to understand.
Good
Name by business meaning
"Order API", "Restaurant Service"
Avoid
Generic names = zero signal
"Server 1", "API", "Queue"
A short description for each component makes feedback much better.
100%
Start by identifying:
  • Users & entry points
  • APIs & services
  • Databases & storage
  • Traffic flow & scale

Round 1 of 4 Architecture Design

Run a simulation to see results.

Time Remaining
60:00
System Design Interview

What are the core functional requirements?
What are the key non-functional constraints?

Questions

Start Evaluation to unlock questions.

EVALUATE MODE

Test yourself like it's the real thing.

A structured 4-module evaluation that mirrors how top companies assess system design candidates.

Architecture Design
Draw your system on the canvas. Define components, connections, and data flow.
FR & NFR Requirements
Answer functional and non-functional requirement questions about your design.
MCQ Round
Multiple choice questions testing your depth on the chosen system.
Tradeoff Analysis
Justify your design decisions and defend your architectural tradeoffs.
AI Report Generated
Choose a Problem
No problem selected
  • 30 min
  • 45 min
  • 60 min
Round 2 of 4
MCQ Round
Answer multiple-choice questions based on your design.

Exit Interview?

You're in the middle of an interview session. Leaving now will end your current attempt.

Your progress will be saved.

Open a saved design

Select a design to load into the canvas.

My Evaluations

Your past evaluation sessions

Here’s a simple request flow that follows the expected layer order.

External User
→
Edge CDN → API Gateway → Load Balancer
→
Compute App Servers / Services
→
DataAccess Cache
→
Storage Database / Search Index
→
Async Queue → Worker

Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

Evaluation Instructions

Read the rules carefully before starting. The test auto-submits on refresh.

Before you start

  • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
  • Don't forget to answer Functional Requirement and Non Functional Requirements.
  • When satisfied with your design, click Next to lock it and view the questions.
  • Please answer final step questions to complete the evaluation.

Dos

  • Do read each question carefully before answering.
  • Do include required components to maximize component coverage.
  • Do save a copy of your design if you want to keep it before submission.

Don'ts

  • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
  • Don't switch app modes or open another tab while the evaluation is running.
  • Don't attempt to edit the design after clicking Next; the workspace will be locked.

All the best!!

Confirm

Input

Notice

Evaluation Report

Evaluation Complete

Generating Your Report

Hang tight — our AI is evaluating your design…

Did you know?

Loading…

Share feedback

Tell us what worked well and what we can improve.

Let's personalize this

Answer a couple of quick questions so we can tailor your journey and missions.

Your welcome gift: of Full PRISM Access

You can change these answers from Mission Control until your missions are done.

Your personalized missions are ready

We tailored these first steps based on your answers.

    PRISM Welcome Gift

    This is a personal welcome gift from PRISM.

    Congratulations.

    You explored PRISM.

    You earned Apprentice.

    As a welcome gift, unlock Full PRISM Access for the configured trial duration.

    This starts Trial. Trial timer begins only after you activate this gift.

    Welcome to PRISM

    We've prepared a personalized Apprentice Journey based on your goals and experience.

    This journey introduces you to the capabilities of PRISM that are most relevant to you.

    Complete all 5 missions to earn your Apprentice title. 5 MISSIONS

    PRISM Surprise Offer

    Complete your Apprentice Journey to unlock a special gift from PRISM.

    • No payment required
    • No credit card required
    • Just complete the journey
    MISSION CONTROL
    0 / 8 missions complete
    NEXT UP Continue your missions
    View full roadmap →
    Mission Complete 0 / 8 Completed Next: Keep going
    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary