Reliability, Schemas & Operations
Dead-Letter Topics
gcloud pubsub topics create order-events-dlq
gcloud pubsub subscriptions create inventory-sub \
--topic=order-events \
--dead-letter-topic=order-events-dlq \
--max-delivery-attempts=5
# After 5 failed processing attempts, the message moves to the DLQ
# instead of retrying forever or being silently dropped.Schema Validation
Attaching an Avro or Protocol Buffer schema to a topic validates published messages against an agreed structure BEFORE Pub/Sub accepts them — catching a producer bug at publish time instead of letting malformed data reach every subscriber, each of which would otherwise need its own duplicated validation logic.
Backlog & Scaling
A growing backlog (watch subscription/num_undelivered_messages) means subscribers can't ack messages as fast as they're published — either scale out subscriber capacity (more pull workers, more push instances) or fix the actual bottleneck (a slow downstream call, a rate-limited external API) causing the slow ack rate.
IAM Permissions
gcloud pubsub topics add-iam-policy-binding order-events \
--member="serviceAccount:order-service@my-project.iam.gserviceaccount.com" \
--role="roles/pubsub.publisher"
gcloud pubsub subscriptions add-iam-policy-binding inventory-sub \
--member="serviceAccount:inventory-service@my-project.iam.gserviceaccount.com" \
--role="roles/pubsub.subscriber"Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free