Courses / System Design Interview / Chapter 22
Module 4 · Building Blocks III: Limits, Storage and Search · Chapter 22 of 49
Distributed Task Schedulers
Builds on Core Concepts: RPCs, Consistency, Failures and Time, Distributed Message Queues and Rate Limiters. Next up: Sharded Counters.
Part 1 · What a task scheduler does and what it must guarantee
Work that must run later
A shop sends a reminder at 9 am, a bank builds statements overnight, and an exam portal opens results at noon. Each is work that must run at a chosen time, once, even if a machine dies in between.
A task is one unit of work: a kind, such as send-reminder, and a payload, such as the order number. A task scheduler accepts tasks, stores them, hands each one to a worker when it is due, records how it ended, and tries again when it fails. A worker is a process that executes tasks.
Tasks come in three shapes. A one-off task runs once, as soon as a worker is free: resize this photo. A delayed task runs once at a stated time: send this reminder at 9 am tomorrow. A recurring task repeats on a rule: build the statement at 2 am every night. A recurring task is not a single task that lives forever. It is a schedule that creates a new task each time it fires, so every run has its own record, its own outcome and its own retries.
The message queue chapter showed a queue that delivers messages as soon as a consumer is free. A scheduler adds three things on top: a time, a durable record of each task's state, and rules for failure. Many schedulers are built on a queue or a database table, and the next lessons build one on a table.