Loading Academy Hub...
Build real-time event-driven lakehouse ingestion: Cloud Pub/Sub ordering keys, dead-letter topics, Eventarc triggers, and high-throughput streaming directly into BigQuery via the Storage Write API.
[!NOTE] Google Cloud Pub/Sub provides horizontally scalable, globally distributed asynchronous messaging. Combined with the BigQuery Storage Write API, data engineers achieve sub-second ingestion directly into BigQuery tables with exactly-once delivery guarantees.
tabledata.insertAll: Row-by-row HTTP JSON inserts; expensive and subject to strict rate limits.enable_exactly_once_delivery inside single-region pull leases). Still design BigQuery downstream MERGE / Storage Write API deduplication (Change Data Capture or ROW_NUMBER() OVER (PARTITION BY event_id)), because upstream mobile/API publishers can always emit duplicate retries.insertAll Deprecation Path: Migrate legacy tabledata.insertAll streaming code to the BigQuery Storage Write API (Committed or Pending streams)—higher throughput, free default committed-stream pricing (2 TB/month free), strict protobuf schema enforcement, and optional exactly-once offsets.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
from google.cloud import bigquery_storage_v1
from google.cloud.bigquery_storage_v1 import types, writer
# Configure BigQuery Storage Write Client
write_client = bigquery_storage_v1.BigQueryWriteClient()
parent = write_client.table_path("enterprise-lakehouse-prod", "finance", "fact_transactions")
# Create write stream with COMMITTED mode for exactly-once guarantees
write_stream = types.WriteStream()
write_stream.type_ = types.WriteStream.Type.COMMITTED
stream = write_client.create_write_stream(parent=parent, write_stream=write_stream)
print(f"Created BigQuery Storage Write stream: {stream.name}")Cloud Monitoring Alert: pubsub.googleapis.com/subscription/num_undelivered_messages exceeded 5,000,000.