Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Cloud Pub/Sub (and vs Kafka)

Cloud · GCP

Cloud Pub/Sub (and vs Kafka)

Mediumcloud-09
gcppubsubkafkamessagingstreaming

Question

What is Google Cloud Pub/Sub, and how does it compare to Kafka?

Solution

Cloud Pub/Sub is GCP's managed messaging / event ingestion service. Publishers send messages to a topic; subscriptions deliver those messages to subscribers (push or pull).

Services / apps
      |
      v
  Pub/Sub topic  --+--> subscription A --> Dataflow
                   +--> subscription B --> Cloud Function

Pub/Sub properties

  • Fully managed; no brokers to run
  • At-least-once delivery (design consumers idempotent)
  • Fan-out via multiple subscriptions on one topic
  • Great front door into Dataflow / BigQuery streaming inserts

Pub/Sub vs Kafka

| Dimension | Pub/Sub | Kafka | |---|---|---| | Model | Topic + subscriptions | Topic + partitions + consumer groups | | Ops | Fully managed GCP | Self-managed or managed Kafka | | Replay | Seek / snapshot patterns; retention limits | First-class log replay via offsets | | Ordering | Per ordering key (optional); not global | Per partition | | Ecosystem | GCP-native | Broad streaming ecosystem | | Best fit | GCP event bus, fan-out, serverless | Durable log, complex stream processing |

Interview tip: "Pub/Sub = managed publish/subscribe on GCP; Kafka = durable partitioned log." Emphasize fan-out subscriptions vs Kafka consumer groups, and always mention idempotent consumers.

PreviousNext