Exams / GCP-PDE / D1 Ingesting and processing the data
Ingesting and processing the data (part 1 of 3)
- Exam domain: Ingesting and processing the data
1. Streaming ingestion: Pub/Sub → Dataflow → sink
Pub/Sub is "an asynchronous and scalable messaging service that decouples" producers from consumers, so bursts are buffered independently of processing. Dataflow runs Apache Beam pipelines and "uses the same programming model for both batch and" streaming.
| Need | Pick |
|---|---|
| Bursty global devices / clickstream / votes | Pub/Sub (devices or gateways publish directly) |
| Stateful processing, windows, late data | Dataflow (Beam) |
| Ad hoc analytics | BigQuery |
| Low-latency serving of live results | Bigtable |
| Per-message serverless job | Pub/Sub push subscription → Cloud Run function |
Pub/Sub subscriptions:
- Push: "In push delivery, Pub/Sub initiates requests to your subscriber"; authentication uses a signed JWT.
- Unacked or late-acked messages are redelivered: "Leaving messages unacknowledged, whether intentionally or not, creates backlog issues and duplicate deliveries."
- Seek can replay previously acknowledged messages if acknowledged-message retention is on.
2. Windows, watermarks, late data
| Window | Use |
|---|---|
| Fixed (tumbling) | Non-overlapping periods |
| Sliding (hopping) | Moving average: size 30 s, period 5 s |
| Session | "A session window contains elements within a gap duration of another element." Visit = 30 min gap |
A watermark is Dataflow's estimate of event-time completeness; data behind it is late data. Trigger AfterWatermark.pastEndOfWindow() fires when the window closes. Data freshness (event time to processing time) above your SLA means the pipeline is slow: optimize or add workers.
3. BigQuery ingestion
| Source | Path |
|---|---|
| Custom streaming / preprocessing at scale | Dataflow ("If you must support custom streaming data sources, or preprocess ... use Dataflow") |
| Exactly-once streaming | Dataflow STORAGE_WRITE_API mode; 3 GBps in us/eu multi-regions, 300 MBps elsewhere |
| Scheduled files from Cloud Storage | BigQuery Data Transfer Service |
| On-prem MySQL, scheduled/incremental | DTS MySQL connector (needs watermark columns) |
| Oracle / MySQL / PostgreSQL CDC | Datastream (private connectivity for VPC sources) |
| No-code scheduled transform | BigQuery pipelines with data preparation |
| Bad CSV rows | Dataflow CSV template with badRecordsOutputTable (dead-letter table) |
| Kafka | Dataflow Kafka to BigQuery template, brokers reachable from workers |
Read side: use column projection or a query so Dataflow reads only needed columns. Large joins: CoGroupByKey rather than side inputs.
4. Data protection and networking
- BigQuery CMEK: keys from Cloud KMS; create CMEK-protected storage and migrate.
- Sensitive Data Protection (Cloud DLP):
content.inspectfor in-flight detection; de-identify inside a Dataflow pipeline before the sink. - Dataflow without external IPs needs Private Google Access on the subnetwork.
- Batch job failure after starting with DoFn errors: "The pipeline fails completely when a single bundle fails four times."
5. Moving data in bulk
- Storage Transfer Service uses TLS, also over Interconnect; agents handle on-premises sources.
- Hours for petabytes → Interconnect + Storage Transfer Service; Transfer Appliance is for slow links and takes much longer.
- Turbo replication: "For buckets using turbo replication, the RPO for objects is 15 minutes." Default replication: 12 hours.
Exam traps
- Pub/Sub is not a processor: windowing and late-data handling belong to Dataflow.
- Fixed window ≠ moving average; use sliding with a period.
- Exactly-once into BigQuery = Storage Write API, not the legacy streaming API; regional tables cap at 300 MBps.
- BigQuery encryption keys protect the table; moving to CMEK means new storage + migration in the expected answer.
- Dead-letter/bad-record tables beat
max_bad_records=0. - Removing hops lowers latency (Dataflow reading Kafka directly).
- Old names: Cloud Functions = Cloud Run functions; Cloud IoT Core is retired; "Dialogflow Enterprise Edition" is Dialogflow ES/CX.
Docs
- https://docs.cloud.google.com/dataflow/docs/concepts/streaming-pipelines
- https://docs.cloud.google.com/dataflow/docs/guides/using-monitoring-intf
- https://docs.cloud.google.com/dataflow/docs/guides/write-to-bigquery
- https://docs.cloud.google.com/bigquery/quotas
- https://docs.cloud.google.com/bigquery/docs/mysql-transfer
- https://cloud.google.com/bigquery/docs/workflows-introduction
- https://cloud.google.com/dataflow/docs/guides/templates/provided/kafka-to-bigquery
- https://cloud.google.com/dataflow/docs/guides/templates/provided/cloud-storage-csv-to-bigquery
- https://cloud.google.com/storage/docs/availability-durability
- https://cloud.google.com/pubsub/docs/replay-overview
- https://cloud.google.com/pubsub/docs/pull-troubleshooting
- https://docs.cloud.google.com/pubsub/docs/push
- https://docs.cloud.google.com/pubsub/docs/overview
- https://docs.cloud.google.com/storage-transfer/docs/on-prem-security
- https://docs.cloud.google.com/datastream/docs/manage-private-connectivity-configurations
- https://cloud.google.com/dataflow/docs/guides/routes-firewall
- https://cloud.google.com/dataflow/docs/guides/common-errors
- https://docs.cloud.google.com/dataflow/docs/overview