Apache Beam in HGrid247-3.5
Apache Beam is a unified pipelineprogramming modelfor processing data inbatch and streaming.
Beam provides:Runners allow the same pipeline to run on multiple distributed processing engines.
- SDK for building pipelines
- Runner to execute pipeline
Apache Beam Architecture
The Apache Beam architecture consists of three main components.Beam Pipeline ↓ Beam SDK ↓ Runner ↓ Distributed EngineRunners can run pipelines on various platforms such as:
- Apache Flink
- Apache Spark
- Apache Samza
- Google Cloud Dataflow
Apache Beam Pipeline Model
Pipeline Beam consists of several components:Component Description --------------------------------------------- Pipeline definition of data processing flow PCollection distributed dataset Transform data transformation operations Runner pipeline execution enginePipeline example:Input Source ↓ Transform ↓ Aggregation ↓ Output SinkApache Beam in HGrid247
As of HGrid247-3.5 , workflows can be compiled into Apache Beam programs .
br> The output is usually:workshop_beam.jarRunning Apache Beam Job
Beam Pipelines can be run using a variety of runners .
- Direct Runner
Direct Runner is used to run pipelines locally (usually for testing).
Command:java -cp workshop_beam.jar;BeamRunner\direct-runner\* workshop.Lab01 --input=file:///home/input/* --output=file:///home/outputExplanation:Parameter Meaning workshop_beam.jar Beam app BeamRunner\direct-runner\* Direct runner Beam libraries workshop.Lab01 main class --input data input location --output output location- Spark Runner
Beam Pipelines can also be run using Apache Spark as the execution engine.
Command:spark-submit --class workshop.Lab01 --master yarn \ --jars BeamRunner/spark-runner/beam-runners-spark-2.29.0.jar,\ BeamRunner/spark-runner/beam-sdks-java-io-hadoop-file-system-2.29.0.jar \ workshop_beam.jar \ --runner=SparkRunner \ --input=hdfs:///user/user01/input/* \ --output=hdfs:///user/user01/outputRunners used:SparkRunnerInput and output using HDFS .- Flink Runner
Beam Pipelines can also be run using Apache Flink .
Command:flink run -c workshop.Lab01 \ -j /user01/workshop_beam.jar;/user01/BeamRunner/flink-runer/beam-runners-flink-1.9-2.29.0.jar \ --runner=FlinkRunner \ --input=hdfs:///user/user01/data/input \ --output=hdfs:///user/user01/outputRunners used:FlinkRunner- Google Dataflow Runner
Beam Pipelines can also be run on the cloud using Google Cloud Dataflow .
Command:java -jar workshop_beam.jar \ --runner=DataflowRunner \ --project=<YOUR_GCP_PROJECT_ID> \ --region=<GCP_REGION> \ --tempLocation=gs://<YOUR_GCS_BUCKET>/temp/Important parameters:Parameter Description ------------------------------------------ project ID project Google Cloud region region cloud tempLocation temporary file location in GCS- Samza Runner
Pipeline Beam can also be run using Apache Samza .
Command:mvn exec:java -Dexec.mainClass=wokshop.Lab01 \ -Psamza-runner \ -Dexec.args="--runner=SamzaRunner \ --inputFile=/path/to/input \ --output=/path/to/counts"Runners used:SamzaRunnerApache Beam Runner Comparison
Runner Use Case DirectRunner Local testing SparkRunner Batch processing pada Spark cluster FlinkRunner Streaming/Batch processing DataflowRunner Cloud-native pipeline SamzaRunner Event-driven streamingApache Beam Advantages
Using Apache Beam provides several advantages.Unified Batch and Streaming
The same pipeline can be used for:
- batch processing
- streaming processing
Portable Pipelines
Pipelines can be run on multiple runners.Scalable
Can be run on large clusters.Cloud Integration
Beam can run on:
- Spark
- Considerable
- Dataflow
- Samza