Google Cloud Architect: Pub/Sub Delivery Semantics

Pub/Sub delivery semantics are easiest to misunderstand when architecture diagrams reduce messaging to a clean arrow from publisher to subscriber. In production, the difficult questions begin after the publish call succeeds: how long a subscriber has to acknowledge a message, what happens when processing outlives that deadline, whether redelivery implies duplicate business work, how ordering interacts with retries, and what evidence proves a message was handled. Those details determine whether a messaging system behaves like a resilient buffer or an unpredictable source of duplicate effects.

For Professional Cloud Architect decisions, delivery behavior should follow workload requirements rather than a preference for stronger-sounding guarantees. Google Cloud provides several Pub/Sub features that influence the contract, but the application still owns important decisions about idempotency, acknowledgment timing, retry handling, ordering, and downstream side effects.

At-least-once delivery makes acknowledgment part of correctness

The ordinary Pub/Sub model assumes that a message may be delivered again when the service cannot establish that processing completed successfully. A subscriber receives a message with an acknowledgment deadline. If the message is acknowledged in time, the service can remove it from normal delivery. If the deadline expires, the client negatively acknowledges it, or connectivity prevents acknowledgment from reaching the service, the message can be delivered again. That behavior protects against silent message loss, but it also means application logic cannot equate “I received this message” with “this business action will happen exactly once.”

The acknowledgment should therefore follow the point at which the subscriber has created a durable result or a durable handoff. Acknowledging before a database transaction, object write, or downstream publish is safely committed can convert a transient process failure into lost work. Acknowledging too late has the opposite effect: healthy long-running processing may look abandoned and trigger unnecessary redelivery. The correct deadline strategy depends on the actual processing path, not on a generic timeout value.

Redelivery and duplicate effects are different problems

Redelivery is a transport event. Duplicate effect is an application outcome. A message can be delivered twice without causing a duplicate charge, duplicate ticket, or duplicate database mutation when the subscriber uses an idempotency key or another durable record of completed work. Conversely, a message can be delivered once and still cause duplicate effects if the subscriber repeats a non-idempotent downstream action after losing its own local state.

This distinction changes how teams investigate incidents. Pub/Sub metrics and subscriber logs can show acknowledgment expirations or redelivery, but the business system must show whether the same logical operation was applied more than once. Message IDs, ordering keys, business transaction IDs, and downstream request IDs should be correlated so an operator can separate harmless transport repetition from actual duplicated state changes.

Exactly-once delivery narrows one failure mode, not the whole transaction

Pub/Sub exactly-once delivery strengthens the acknowledgment contract for supported subscriptions. A subscriber can determine whether an acknowledgment succeeded, and a successfully acknowledged message is not redelivered. The service also rejects stale acknowledgment IDs when a newer delivery is current. Those properties remove important ambiguity between subscriber and messaging service, especially when a client is unsure whether its acknowledgment reached Pub/Sub.

Scope of the exactly-once guarantee (October 2026): Google Cloud currently supports this feature for pull subscriptions, including StreamingPull, and the delivery guarantee applies within a cloud region when subscribers connect consistently to that region. Push and export subscriptions are not covered. The feature also does not deduplicate distinct messages that an upstream publisher sends twice. Applications must therefore pair an appropriate pull subscription and regional endpoint strategy with durable business idempotency for any irreversible side effect.

They do not create a distributed transaction with every system the subscriber touches. If a worker writes to a database, calls a payment API, and then acknowledges the message, the business side effects still need a recovery design for crashes between those steps. Exactly-once messaging is most useful when it is combined with idempotent writes, transactional outbox or inbox patterns where appropriate, and explicit reconciliation for irreversible external actions.

Ordering changes throughput and recovery behavior

Ordering keys allow related messages to be delivered in order, which is useful when later events depend on earlier state. The cost is coupling: one slow or failing message can delay subsequent messages for the same key. With ordered delivery, retry and acknowledgment behavior must preserve the sequence rather than treating every message as fully independent. Exactly-once delivery can be combined with ordering, but acknowledgments must respect ordering constraints and throughput per ordering key is inherently more limited than fully parallel consumption.

The architectural question is whether the business domain genuinely requires a total sequence for a given entity. Many systems need ordering per account, device, document, or workflow rather than one global sequence. Choosing a sufficiently granular key lets unrelated work continue while preserving the dependency that actually matters. A key that is too broad converts an event platform into a serial queue; a key that is too narrow pushes ordering bugs into the consumer.

Retry policy should distinguish transient failure from poisoned work

Retries are valuable for network errors, temporary dependency failures, and short-lived capacity problems. They are destructive when a message contains invalid data, violates a business invariant, or repeatedly triggers the same deterministic application error. A subscriber that blindly retries every failure can spend capacity on work that will never succeed while increasing latency for healthy messages.

Dead-letter handling creates a bounded path for repeated failure, but a dead-letter topic is not a garbage bin. Operators need enough context to explain why a message was moved, whether its schema is still understood, what downstream state may already exist, and what safe replay would mean. A replay process should avoid bypassing the same validation that rejected the message originally. When the failure is caused by code or configuration, remediation should be deployed before replay begins.

Flow control protects the subscriber from its own backlog

Pull subscribers can receive messages faster than their workers or dependencies can finish them. Client flow control limits the number or bytes of outstanding messages so memory, connection pools, and downstream services are not overwhelmed. This is a different control from subscription backlog: backlog measures work waiting in Pub/Sub, while flow control bounds work already handed to a subscriber but not yet acknowledged.

A resilient design lets backlog absorb short producer bursts instead of forcing every consumer to scale instantly. The Pub/Sub model is valuable precisely because producers and consumers can operate at different rates, but that decoupling is useful only while the accumulated age of unprocessed messages stays inside the business latency objective. Operators should watch oldest-unacked age, acknowledgment deadline expirations, subscriber throughput, and downstream saturation together.

Subscriber concurrency adds another layer to the acknowledgment contract. Increasing the number of parallel callbacks can improve throughput when messages are independent, but it also increases the number of outstanding acknowledgments and the pressure on shared databases, APIs, and connection pools. A subscriber that pulls faster than its dependencies can commit work out of order even when message delivery itself is functioning correctly. Concurrency should therefore be bounded by downstream capacity and by the business ordering assumptions of the handler.

Long-running handlers also need a deliberate acknowledgment-extension strategy. Supported client libraries can extend deadlines while work is in progress, but extension should not hide a stuck worker forever. Teams should define a maximum processing window after which the message is allowed to re-enter retry handling, with logs that preserve the original start time and processing attempt. That creates a difference between legitimately slow work and work that is no longer making progress.

Retention and replay are architectural controls

Message retention determines how long the platform can preserve unacknowledged work and, when retention of acknowledged messages is configured, how far operators can seek or replay a subscription. Longer retention improves recovery options but increases storage cost and can expose old payloads for longer. Short retention reduces those costs but narrows the time available to repair a broken subscriber before data must be reconstructed from another source.

Replay also changes the meaning of idempotency. A consumer that was safe against immediate redelivery may still fail when operators intentionally replay hours or days of history after the downstream database has evolved. Schema versions, deduplication windows, state transitions, and external side effects all need a policy for historical messages. “We can seek backward” is an operational feature, not proof that replay is safe.

Cost follows message shape and recovery behavior

Messaging cost is influenced by volume, payload size, regional data movement, retention, and the amount of repeated delivery created by slow or failing consumers. A design that constantly lets acknowledgment deadlines expire can pay both an operational and financial penalty. Similarly, excessive topic fan-out can be architecturally justified, but each independent subscription creates its own backlog and processing path.

Cost governance should therefore measure useful business events rather than only raw message counts. Cost per successfully processed event, redelivery rate, backlog age, and subscriber utilization reveal whether spend is buying resilience or merely funding repeated work. Those measures are especially important when an architecture adds subscriptions for analytics, audit, search, and downstream automation.

Schema evolution can complicate redelivery and replay even when transport semantics are sound. A message produced under an older schema may return after the consumer has been deployed with new validation logic. Consumers should either preserve backward-compatible decoding for the supported replay window or route incompatible versions to an explicit migration path. Otherwise an operational recovery can turn into a poison-message storm simply because software moved forward while retained messages did not.

The delivery contract should be testable during failure

A production readiness test should kill a subscriber after a downstream write but before acknowledgment, delay processing beyond the normal acknowledgment deadline, reject malformed payloads, interrupt network access to Pub/Sub, and replay older messages. The expected result must be explicit for each experiment. A system that works only when every dependency is healthy has not demonstrated its delivery semantics.

The final architecture decision is a set of coordinated promises: which messages may be delivered more than once, which business effects are idempotent, where ordering is required, how poison messages are isolated, how much backlog is acceptable, and how operators prove acknowledgments and downstream outcomes. Pub/Sub provides mechanisms for those promises, but the application and operating model determine whether the promises are actually true.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!