Batch processing

On this page 7

Batch processing is a data processing model in which a job reads a bounded set of data, such as all transactions from yesterday or every file in a folder, processes it as a single unit of work, and writes the complete result before finishing. Jobs typically run on a schedule or on a trigger, and results become available only after the whole batch completes.

In data processing and data engineering, batch processing is the established approach for ETL and ELT pipelines, warehouse loads, reporting, billing runs and model training. It trades latency of minutes to hours for high throughput, simple recovery and reproducible results, in contrast to stream processing, which handles unbounded data continuously.

How batch processing works

A batch job follows a read, transform, write cycle over a defined input. The input is fixed when the job starts, typically identified by a time partition (for example the date 2026-11-09) or a list of files. The job applies transformations such as data cleaning, deduplication, joins, data aggregation and enrichment, and then writes output to a target table, file or system.

Because the input is bounded, the job knows when it is complete, and it can sort, join and aggregate the whole dataset at once. Large batch jobs are executed by distributed engines that split the data into partitions, process them in parallel on many machines and combine the results, a pattern popularized by MapReduce and refined by Apache Spark.

The main components of a batch system are summarized below.

ComponentRoleCommon examples
Storage layerHolds input and output dataObject storage, distributed file systems, warehouses
Processing engineExecutes transformations in parallelApache Spark, MapReduce, warehouse SQL engines
OrchestratorSchedules jobs and manages dependenciesApache Airflow, Dagster, cron
Data formatDetermines read efficiencyParquet, ORC, Avro, CSV
Metadata and catalogTracks tables, schemas and partitionsHive metastore, data catalogs
MonitoringDetects failures and late runsJob logs, SLA alerts, data quality checks
Components of a batch processing system

Key parameters of a batch job

Batch design revolves around a few parameters that determine freshness, cost and reliability. The most important is the batch window: the interval of data each run covers and the time available to process it before downstream consumers need the result.

ParameterTypical rangeWhat it affects
Schedule frequencyEvery 15 minutes to monthly, most often dailyData freshness and compute cost
Batch sizeMegabytes to many terabytes per runRuntime, memory and parallelism
Partition sizeCommonly about 100 MB to 1 GB per taskParallel efficiency and overhead
Processing windowMinutes to several hoursDeadline for downstream reports
Retry policyOne to several automatic retriesResilience to transient failures
Load strategyFull reload or incrementalRuntime and correctness of updates
Batch job parameters and their effects

Incremental loads, which process only new or changed records since the last run, reduce cost dramatically but require reliable change detection through timestamps, change data capture or watermark columns. Full reloads are simpler and self-correcting but become impractical as data grows.

Batch processing compared with stream processing

Batch and stream processing differ mainly in how data is bounded and therefore in latency. Many organizations run both: streaming for operational reactions within seconds and batch for authoritative, reconciled results.

AspectBatch processingMicro-batchStream processing
InputBounded datasetSmall bounded slicesUnbounded event stream
Typical latencyMinutes to hoursSeconds to minutesMilliseconds to seconds
CompletenessKnown when the job endsPer sliceEstimated with watermarks
RecoveryRerun the jobRerun the sliceCheckpoints and replay
Operational complexityLowestModerateHighest
Typical usesWarehouse loads, billing, trainingNear-real-time dashboardsFraud detection, alerting
Batch, micro-batch and stream processing

Two architecture patterns combine them. The Lambda architecture runs a batch layer and a speed layer in parallel and merges their views, at the cost of maintaining two code paths. The Kappa architecture treats everything as a stream and reprocesses history by replaying the log. Modern engines narrow the gap by running the same code in both batch and streaming modes.

Designing reliable batch pipelines

The most important property of a production batch job is idempotency: running it twice for the same input must produce the same output, not duplicate it. This is usually achieved by overwriting a whole partition or by merging on a key, rather than appending rows blindly.

  • Parameterize each run by its logical date, so any day can be reprocessed or backfilled.
  • Write to a staging location first and publish atomically, so consumers never read half-written results.
  • Validate data before publishing, checking row counts, null rates and key uniqueness.
  • Declare dependencies explicitly in the orchestrator instead of relying on fixed start times.
  • Use columnar formats and partition pruning so jobs read only the data they need.

Common failure symptoms point to specific causes, as the table below shows.

SymptomLikely causeRemedy
Duplicated rows after a retryNon-idempotent appendOverwrite partitions or merge on keys
One task runs far longer than othersData skew on a hot keySalt keys or repartition
Job misses its deadlineGrowing data with full reloadsSwitch to incremental processing
Reports miss recent recordsLate-arriving data after the runReprocess a trailing window
Many tiny output filesExcessive partitioningCompact files after writing
Batch processing problems and remedies

Limitations of batch processing

The fundamental limitation is latency: a daily job means decisions are based on data that is up to a day old, which is unacceptable for fraud prevention, live personalization or operational alerting. Batch systems also concentrate load in peak windows, often overnight, which can create contention when many jobs depend on the same sources. Finally, long dependency chains mean that one late upstream job delays everything downstream.

In plain words

Batch processing means collecting work and doing it all at once. A laundromat does not wash each sock the moment it gets dirty. It waits for a full load and runs the machine.

Computers do the same with data. Every night, a system might take all of the day’s sales and total them in one run. It is efficient and easy to repeat, but the results are only as fresh as the last run.

A real-world example

A mobile network operator produces customer bills once a month from call, data and messaging records. Each day a batch job loads roughly a billion usage records into partitioned Parquet files. On the billing date a Spark job joins the month’s usage with tariff plans and discounts, computes charges per subscriber and writes invoices to a staging table.

Validation checks compare totals with the previous month and flag subscribers whose bill changed by more than a set threshold. Only after the checks pass is the staging table published atomically to the invoicing system. When a tariff error was once discovered, the team reran the job for the affected month and regenerated correct invoices without any manual data repair.