What Is Batch Processing? Definition, Examples, and When to Use It
Batch processing collects data over a period of time and then processes all of it at once as a single job, usually on a schedule, instead of handling each record the moment it arrives. A payroll run that reads a month of timesheets on the last day of the month and produces every paycheck in one pass is a batch job. The defining features are a bounded input, a scheduled start, and a design that favors total throughput over the speed of any single record.
What Batch Processing Means
A batch is a set of records that is complete before the work starts. The job reads the whole set, applies the same steps to every record, and writes the results out at the end. Nothing in the batch counts as done until the job finishes, so a batch job is measured by how long the whole run takes rather than by how quickly one record is handled.
The term "bulk processing" is often used for the same idea, and "batch computing" or "batch mode" describes a system that runs this way. Early mainframes worked almost entirely in batch mode, and the pattern is still the standard way to run reports, billing, and data loads today.
Examples of Batch Processing
- Nightly payroll runs. Hours are collected all month and every employee is paid in one job.
- End-of-day bank settlement. A bank nets the day's transfers between accounts after the business day closes.
- Monthly billing. A utility or a software company reads a month of usage and produces every invoice at once.
- ETL loads into a data warehouse. ETL stands for extract, transform, load: the job pulls records from source databases, reshapes them, and writes them into the warehouse on a schedule.
- Report generation. Daily sales reports and weekly summaries are built from the previous period's data.
- Model training. A recommendation model is retrained each night on the day's clicks and purchases.
- Batch image processing. A photo service resizes and watermarks every upload from the day in one job rather than one image at a time.
Characteristics of a Batch Job
The input is bounded. The job knows the full set of records before it starts, so it can split the work across machines and report exact progress.
The start is scheduled. A batch job runs at a fixed time, such as 2 a.m. every night, or when a trigger fires, such as the moment the day's input files are available.
Throughput matters more than latency. Throughput is the amount of work finished per unit of time, and latency is the delay before one record is handled. A batch job accepts hours of latency in exchange for processing millions of records per hour at low cost.
Retries are simple. If the job fails halfway, the usual fix is to rerun it, because the input has not changed. Batch jobs are therefore written to be idempotent, which means running them twice produces the same result as running them once.
Tools for Batch Processing
Small jobs need nothing more than cron, the scheduler built into Unix-like systems, and a shell or Python script. Large jobs that must be split across many machines use Apache Spark or Hadoop MapReduce, both of which divide the input into partitions and process the partitions in parallel. When a pipeline has many dependent steps, an orchestrator such as Apache Airflow runs them in the right order and retries the ones that fail. Cloud providers offer managed versions of the same idea, such as AWS Batch and Google Dataflow running in batch mode.
Batch Processing vs Stream Processing
Stream processing is the opposite pattern: each record is handled within milliseconds of the time it is produced, and the input never ends. The full comparison, including how to choose between them, is in What is batch processing vs. stream processing and when should you use each?. This page covers only the batch side.
| Batch | Stream | |
|---|---|---|
| Input | Bounded, complete before the start | Unbounded, arrives continuously |
| Latency | Minutes to hours | Milliseconds to seconds |
| Typical job | Payroll, billing, ETL | Fraud checks, live dashboards |
| Failure handling | Rerun the job | Checkpoint and replay from a queue |
The diagram below shows the two patterns side by side.
When to Use Batch Processing
Batch is the right choice when all three of the following are true.
- Results are needed hourly or daily, not within seconds of each event.
- The data is complete before the job starts, so nothing is missing at run time.
- Cost matters more than freshness, because a scheduled job can run on cheap off-peak capacity.
If a result is needed the moment an event happens, stream processing is required instead. Many systems combine the two: a stream handles the live path, and a nightly batch recomputes the totals from the full record. That combination is the Lambda architecture, which is explained in What is the Lambda architecture and the Kappa architecture in big data, and how do they differ?.
A common design places a message queue between the producers and the batch job. Producers keep writing while the job is idle, and the job reads the accumulated messages when its schedule fires. Queues are covered in What is a message queue and why are queues used in scalable system design?.
How to Prepare
- State the three conditions. When an interviewer asks whether a report should be batch or streaming, say how fresh the result must be, whether the input is complete, and what the cost budget is.
- Know one tool per size. Cron for a single machine, Spark for a cluster, and Airflow for a pipeline of dependent jobs.
- Practice the retry story. Explain what happens if the job fails at record 4 million out of 10 million and why idempotent writes make the rerun safe.
- Study the building blocks. Grokking System Design Fundamentals covers batch and stream processing together with queues, caches, and storage.

GET YOUR FREE
Coding Questions Catalog

$99

$197

$72