GCP Prep
Browse all topics
Data & Analytics4 min readUpdated August 26, 2026

Pub/Sub and Messaging

In one sentence

Pub/Sub is a queue that lets one system tell others something happened, without knowing or caring who is listening.

What it is

Pub/Sub is a messaging service. Publishers send messages to a topic. Subscribers create subscriptions to that topic and receive copies of the messages. The publisher does not know who the subscribers are, and adding a new subscriber requires no change to the publisher.

The service holds messages durably until they are acknowledged, so a subscriber can be slow, restart, or be offline briefly without messages being lost.

Why it matters

Direct synchronous calls between services couple them tightly. If the receiver is slow, the caller is slow. If the receiver is down, the caller fails. Adding a second consumer means changing the caller.

Messaging removes all three problems. The publisher's job ends when the message is accepted. Consumers process at their own pace, retry independently, and can be added or removed without touching the publisher. This is why event-driven architecture is built on it.

Key concepts

  • Topic — the named channel messages are published to.
  • Subscription — an independent stream of messages from a topic. Each subscription receives every message, so two subscriptions mean two copies.
  • Push and pull — push delivers messages to an endpoint you provide; pull has your consumer request them. Push suits serverless handlers; pull gives you control over rate.
  • Acknowledgement — the consumer confirms successful processing. Unacknowledged messages are redelivered after the acknowledgement deadline.
  • At-least-once delivery — the default guarantee. A message may be delivered more than once, so consumers must be idempotent.
  • Ordering key — guarantees ordered delivery for messages sharing a key. It reduces throughput, so enable it only where order genuinely matters.
  • Dead-letter topic — after a configured number of failed attempts, the message is moved aside rather than retried forever.
  • Message retention and replay — messages are retained for a configurable period and a subscription can be rewound to reprocess history.

How a message flows

  1. 1A publisher sends a message to a topic and receives confirmation
  2. 2The message is stored durably and copied to every subscription
  3. 3Subscription A delivers to an analytics consumer; subscription B delivers to a notification service
  4. 4Each consumer acknowledges independently once it has finished processing
  5. 5Unacknowledged messages are redelivered after the deadline expires
  6. 6Messages that fail repeatedly are routed to a dead-letter topic for inspection
One publish, several independent consumers, each with its own progress.

Common use cases

  • Decoupling microservices so a slow downstream service does not slow the caller.
  • Ingesting event streams from applications, devices or clickstreams into analytics.
  • Fanning one event out to several independent consumers — search indexing, notifications, auditing.
  • Buffering traffic spikes so downstream systems process at a sustainable rate.
  • Triggering serverless functions and Cloud Run services from events.
  • Reliably delivering work to background processors with retry and dead-letter handling.

Certification relevance

Where this topic appears, and how deeply each exam goes into it. These are our own assessments based on published exam guides.

Practice questions

Data & Analytics practice questions

8 original questions with full explanations.