Why batch processing is a scheduling problem wearing a data-processing costume
Batch processing is a scheduling problem: the computation is a few lines, and placement, failure and re-execution decide whether the job finishes.
The computation in a batch job is the smallest part of the system. A mapper turns each record into a key and a value, and a reducer combines the values for each key. The hard work is everything around those functions: deciding which machine runs each piece, keeping data close to that machine, and rerunning only the pieces that were lost when a machine disappeared. Those decisions determine whether the job finishes and how long it takes.
Placement starts with where the input lives. The input is split into blocks, and the scheduler assigns each map task to a machine that already holds one of those blocks, so the task reads from a local disk instead of across the network. When no such machine is free, the task runs elsewhere and pays a network trip for every block it reads. The mapper then emits key-value pairs, the framework groups them by key, and reducers fetch the groups they own. Each step is a unit of work with an assigned location and a known input, which is what lets the scheduler move it. The same arrangement that makes storage and compute one system also means that storage placement decisions shape compute speed. Splitting the data into blocks is therefore a scheduling decision, made before a single line of the mapper runs.
The abstraction hides failure. A cluster of many machines always has some machine that is down, slow, or reclaimed, so the scheduler must treat loss as a routine event. Consider a task that appends its output directly to the final path as it runs. If the machine is reclaimed partway through, the file holds part of a result. The scheduler retries the task, the retry appends again, and the job reports success while some records are counted twice. Nothing in the mapper was wrong; the output contract was. Restarting the whole job hides the same trap in a milder form: it discards finished work, so the naive loop becomes unaffordable as the cluster grows. A task that is not deterministic, writes outside its own output, or publishes partial results breaks the one guarantee retry depends on, which is that running it again gives the same answer.
Design the retry before the computation. Keep each task small enough that losing one wastes little work. Make each task deterministic: the same input must produce the same output, with no side effects beyond its own result. Write output to a temporary location and publish it only when the task succeeds, so a killed attempt leaves nothing visible. Keep input close to the machines that will process it, and if it lives in a remote store, copy it locally for the job rather than reading it again in each stage. Judge the job by attempts per task, not by elapsed time alone. On unreliable hardware, a healthy job runs more attempts than tasks, and that extra work is the scheduler doing its job. Before you ship, ask one question: if this machine disappears at any moment, does a rerun produce exactly the output the first run would have?
- tasks per job
- thousands
- task retries
- percent of tasks
- network trip per block read
- one
- mapper logic
- a few lines
Each job splits into many independent units, so one lost machine affects one unit rather than the whole run.
A healthy run reruns only a small share of tasks, so retries cost a fraction of total work.
A task running away from its data pays this trip for every block it reads, which placement near the data avoids.
The user-written function is small; most of the system is placement, retry and output handling.
The first version of a batch job looks like a loop. Read the input files, compute a result for each record, write the output, and wrap the whole run in a retry. On a small machine this works well enough that nobody questions it.
The wall arrives with scale. A cluster of thousands of machines always has failures somewhere, so the whole run is interrupted again and again. Each restart throws away the work already finished, and a job that needed hours of compute can keep starting over without ever completing.
The MapReduce paper describes the answer: split the job into tasks that can be re-executed independently on commodity machines, and let the scheduler place each task where its input already sits. A lost machine then costs one task, not the run, and the scheduler reruns that task elsewhere.
The non-obvious lesson is that the algorithm is the easy part. What makes unreliable hardware usable is the scheduler's ability to redo one small unit safely, without disturbing anything that already finished, so that any machine can disappear without changing the result.