← Lessons

quiz vs the machine

Silver1110

System Design

Batch vs Stream Processing

Processing data in scheduled chunks versus record by record as it arrives.

4 min read · intro · beat Silver to climb

Two timing models

Data processing splits along when work happens relative to when data arrives.

  • Batch processing collects records over a window, then processes the whole group on a schedule, such as hourly or nightly. It is simple, easy to retry, and efficient for large volumes.
  • Stream processing handles each record or tiny micro batch within seconds of arrival. It powers dashboards, fraud checks, and alerts that cannot wait for the next batch.

Trade offs

Batch jobs are cheaper per record and easier to reason about because the input set is fixed when the job starts. Streams give low latency but must handle unbounded input, out of order events, and state that lives across time. Many teams run both in a layered design where a stream gives fast approximate answers and a batch job later produces the exact corrected result.

Key idea

Batch trades latency for simplicity over a fixed input, while streams trade simplicity for low latency over unbounded input.

Check yourself

Answer to earn rating on the learn ladder.

1. What is a key advantage of batch processing?

2. Why do teams sometimes run streaming and batch together?