Apache Beam
One programming model for batch and streaming pipelines that can run on several different processing engines.
Apache Beam is a programming model rather than an engine. You write a pipeline once using a Beam SDK and then choose the system that executes it, such as Apache Flink, Apache Spark or Google Cloud Dataflow. The documentation describes Beam as a unified model for defining both batch and streaming data parallel processing pipelines.
What is Apache Beam?
Apache Beam is a unified model for defining both batch and streaming data parallel processing pipelines. It is a project of the Apache Software Foundation.
Beam separates two things that are usually joined together. The description of the work is written in a Beam SDK. The execution of that work is done by a runner, which translates the pipeline for a specific processing system.
Why Apache Beam exists
Batch and streaming are often written twice, once for files that have ended and once for events that keep arriving. Beam expresses both with the same set of concepts, so one pipeline can handle bounded datasets and unbounded streams.
The second reason is portability. Because the runner is chosen separately, the same pipeline can move to another engine without the logic being rewritten.
How a Beam pipeline executes
The model has a small vocabulary.
- A Pipeline is the graph of transformations you build.
- A PCollection is a dataset or stream inside the pipeline, described as an unordered bag of elements.
- A PTransform is a processing step applied to a PCollection.
- Windowing subdivides a PCollection into finite windows using the timestamps on its elements.
- A watermark estimates when all the data for a window has arrived.
- A trigger decides when the aggregated result for a window is emitted.
- A runner executes the finished pipeline on the chosen processing system.
In practice you create a pipeline object in your SDK language, apply transforms to collections and submit the result to a runner. The transforms then process elements in parallel across workers.
Who Apache Beam is for
Beam is aimed at pipeline authors working in one of its SDK languages, and at organisations that want a single approach covering both batch and streaming.
Teams that prefer to stay independent of one processing engine are a natural fit, since the runner is a choice made at submission time rather than a decision baked into the code.
Where Apache Beam stops
Beam does not run anything by itself. It always needs a runner, and the behaviour you observe depends on the engine behind that runner.
You also have to work within the available SDKs. The documentation references Java, Python and Go quickstarts, so a team using another language would need a different approach.
Writing a first Beam pipeline
Three quickstart guides are published, one for each SDK language. The steps are the same in all of them. Create a pipeline object, define the collections that hold your data, apply the transforms that do the work and submit the pipeline to a runner.
For a first run, the Direct Runner executes the pipeline locally, which is useful for testing before you move to Apache Flink, Apache Spark or Google Cloud Dataflow.
Key features of Apache Beam
Capabilities described in the official documentation.
One model for batch and streaming
Bounded datasets and unbounded streams are expressed with the same concepts in a single pipeline definition.
Runner independence
A finished pipeline is submitted to a runner such as Flink, Spark, Dataflow or the local Direct Runner.
Windowing
Elements are divided into finite windows based on their timestamps, so an aggregation has a defined scope.
Watermarks and triggers
Watermarks estimate when a window is complete and triggers decide when the aggregated result is emitted.
Advantages of Apache Beam
Factual advantages that follow from the features above.
Logic written once
The same pipeline covers bounded and unbounded data instead of two separate implementations.
Engine choice stays open
Because execution is delegated to a runner, moving to a different processing system does not require rewriting the pipeline.
Local testing before deployment
The Direct Runner executes a pipeline on a single machine so it can be checked before it reaches a cluster.
Windowing belongs to the pipeline
Grouping unbounded data into time windows is expressed in the pipeline itself rather than left to the engine running it.
Common use cases for Apache Beam
Situations the official documentation describes this tool as being used for.
Batch data processing
A pipeline reads a bounded dataset and processes it from start to finish.
Streaming analytics
An unbounded stream is aggregated using windows, watermarks and triggers.
Data steps in machine learning pipelines
Beam pipelines carry out the data operations that support ML and AI work.
Moving a pipeline to another runner
The same pipeline is submitted to a different execution engine without its logic being rewritten.
Official website
Everything on this page is based on the official documentation for Apache Beam. You can read the source here.
Apache Beam official documentation