Ingesting and processing the data · Topic 4 of 4
Deploying Pipelines with Orchestration and CI/CD
Run pipelines in production: Cloud Composer or Workflows, Dataflow Flex Templates, CI/CD with tests and Cloud Build, and safe streaming job updates.
- 5 min
- Composer for complex DAGs and backfills; Workflows for light serverless API chains.
- Cloud Scheduler triggers; scheduled queries run single SQL steps.
- Flex Templates package Dataflow jobs as container images for repeatable launches.
What it is
A pipeline is operational when it runs by itself on a schedule or event, recovers from routine failures, and can be changed safely through tested, automated releases. Orchestration tools handle the first two; CI/CD handles the third.
How it works
Job automation and orchestration
| Tool | What it is | Choose it when |
|---|---|---|
| Cloud Composer | Managed Apache Airflow; DAGs written in Python | Many dependent tasks across services, retries, backfills, sensors, a large operator library |
| Workflows | Serverless orchestration of API calls, defined in YAML or JSON | A short chain of Google Cloud or HTTP calls, event-driven, pay per step, no environment to run |
| Cloud Scheduler | Managed cron | Trigger one job, function or workflow at fixed times |
| BigQuery scheduled queries | SQL on a schedule | A single SQL step with no dependencies |
| Dataform workflow configurations | Scheduled runs of a Dataform repository | SQL transformation graphs inside BigQuery |
Composer runs a permanent environment, so it costs money even when idle. For "a few steps, triggered when a file arrives, lowest cost", Workflows triggered by Eventarc is often the better answer.
"Backfill", "dependencies between dozens of tasks", "Airflow" and "retry each step" point to Cloud Composer. "Lightweight", "serverless", "call a few APIs in sequence" point to Workflows.
Packaging Dataflow jobs as templates
A Flex Template packages the pipeline as a container image in Artifact Registry plus a template spec file in Cloud Storage. Operators, Composer or Workflows can then launch it with parameters and no development environment.
gcloud dataflow flex-template run "orders-$(date +%Y%m%d-%H%M)" \
--template-file-gcs-location=gs://prod-templates/orders.json \
--region=europe-west1 \
--parameters=input=gs://landing/orders/*.csv
CI/CD for data pipelines
| Stage | Practice |
|---|---|
| Source control | Pipeline code, SQL, DAGs and Terraform all live in Git |
| Continuous integration | Cloud Build runs unit tests on each commit and builds the template image |
| Testing | Beam TestPipeline with assert_that; Dataform compiles and runs assertions |
| Continuous deployment | Deploy to a staging project, run integration tests, then promote to production |
| Infrastructure | Terraform creates datasets, topics, buckets and service accounts in every environment |
import apache_beam as beam
from apache_beam.testing.test_pipeline import TestPipeline
from apache_beam.testing.util import assert_that, equal_to
from orders_pipeline import ParseOrder
def test_parse_order():
with TestPipeline() as p:
out = (p | beam.Create(["o1,10.5,uk"])
| beam.ParDo(ParseOrder()).with_outputs("bad", main="good"))
assert_that(out.good, equal_to(
[{"order_id": "o1", "amount": 10.5, "country": "UK"}]))
Composer DAGs deploy by copying the file into the environment's dags/ folder, which CI can do with one command.
gcloud composer environments storage dags import \
--environment=prod-composer --location=europe-west1 --source=dags/daily_sales.py
Updating streaming pipelines safely
| Option | Effect |
|---|---|
Update (replace the job in place, --update) | Keeps in-flight data and state; transforms must be compatible, renamed steps need a transform name mapping |
| Drain, then start the new job | Stops reading new input, finishes in-flight data, then stops; safe for incompatible changes |
| Cancel | Stops immediately; in-flight data is lost |
A drained Pub/Sub pipeline leaves unread messages in the subscription, so the new job picks up where the old one stopped.
A worked example
A team edits a streaming Dataflow job by hand in production, and releases often break it. The engineer moves the code to Git with unit tests. Cloud Build tests every commit, builds a Flex Template image and deploys to a staging project.
After integration tests pass, the pipeline promotes the template to production and updates the running job in place. If the update fails the compatibility check, it drains the old job and starts the new one.
How the exam asks about this
- "A nightly process has 40 interdependent tasks across BigQuery, Dataproc and Dataflow and needs backfills." Cloud Composer.
- "When a file lands, call two APIs and start a load, with the least cost and no servers." Workflows triggered by an Eventarc event.
- "Deploy a new version of a streaming pipeline without losing in-flight data, and the change is not update-compatible." Drain the running job, then start the new one.
What to remember for the exam
- Composer for complex DAGs and backfills; Workflows for light serverless API chains.
- Cloud Scheduler triggers; scheduled queries run single SQL steps.
- Flex Templates package Dataflow jobs as container images for repeatable launches.
- CI runs unit tests and builds artifacts; CD promotes through staging to production.
- Update in place when compatible; drain when not; cancel loses in-flight data.
Cancelling a streaming job to deploy a new version discards data that was in flight. The exam expects drain or update when data loss is unacceptable.
Common mistakes
Choosing Composer for a single scheduled query. It adds an always-on environment and cost; a scheduled query or Cloud Scheduler is enough.
Manual production changes. Without CI/CD there is no test, no history and no rollback.
Using cancel instead of drain. Cancel stops at once and loses in-flight data.
Check yourself
What is the difference between draining and cancelling a Dataflow job?
Drain stops reading new input and finishes processing in-flight data before stopping; cancel stops immediately and loses in-flight data.
When is Workflows a better fit than Cloud Composer?
For short, serverless sequences of API calls with pay-per-step pricing and no always-on environment.
What does a Dataflow Flex Template contain?
A container image of the pipeline in Artifact Registry plus a template spec file in Cloud Storage, launched with parameters.
Topic 4 of 4 in Ingesting and processing the data
Test yourself on Ingesting and processing the data
The full Google Cloud Professional Data Engineer question bank has 733 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Google Cloud. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.