Scalable event streaming and messaging platform for asynchronous communication and real-time data processing.
What is Google Cloud Pub/Sub?
Google Cloud Pub/Sub is a fully managed messaging service based on the publish-subscribe pattern. The system decouples senders (publishers) and receivers (subscribers) of messages, enabling highly scalable, resilient event-driven architectures. Publishers send messages to topics, while subscribers consume these messages independently through subscriptions. This architecture allows multiple services to process the same events without needing to know about each other.
A core feature is the exactly-once delivery guarantee, ensuring that each message is processed exactly once, even during system failures or retries. This is achieved through a combination of unique message IDs, server-side deduplication, and acknowledgment mechanisms.
Note: The previously available cost-optimized variant, Pub/Sub Lite, was fully shut down on June 30, 2026. Google recommends existing Pub/Sub Lite users migrate to Pub/Sub Standard, or, for partition-based, highly cost-sensitive workloads, to Google Cloud Managed Service for Apache Kafka.
Pub/Sub integrates seamlessly with other Google Cloud services: BigQuery subscriptions enable direct streaming to data warehouses without additional ETL code, Dataflow can transform messages in real-time, and Cloud Functions can be triggered by events. Schema validation with Avro and Protocol Buffers ensures data quality, while message ordering with ordering keys guarantees correct sequence for event sourcing and change data capture. The global infrastructure automatically scales from a few messages per second to millions, without manual intervention.
Common Use Cases
Event-driven Microservices
Pub/Sub serves as a central event bus for microservices architectures. Services publish domain events (e.g., OrderCreated, PaymentProcessed) to topics, while other services asynchronously consume these events. This decouples services, enables independent scaling, and simplifies implementation of CQRS and event sourcing patterns.
Streaming Analytics with Dataflow
Combination of Pub/Sub and Dataflow for real-time data analysis. Pub/Sub collects events from various sources (web, mobile, IoT), while Dataflow aggregates, transforms, and analyzes them in real-time. Results are written to BigQuery, Cloud Storage, or other systems.
IoT Data Ingestion
Pub/Sub automatically scales for many concurrently sending IoT devices. The global infrastructure ensures low latency, while configurable message retention buffers temporary failures of downstream systems.
Real-time Notifications
Push subscriptions enable real-time notifications to webhooks or Cloud Functions. This is suitable for user notifications, alerts, or workflow triggering. Pub/Sub supports reliable delivery with automatic retries and dead letter topics for failed messages.
Log Aggregation
Centralized log collection from distributed systems. Applications and services send logs to Pub/Sub topics, then processed by different consumers: long-term storage in Cloud Storage, real-time monitoring, SIEM integration, or compliance archiving.
ETL Pipelines with BigQuery Subscriptions
BigQuery subscriptions write Pub/Sub messages directly into BigQuery tables without additional code. Schema validation ensures data quality, while automatic partitioning and clustering optimize query performance.
Asynchronous Task Queues
Pub/Sub as a robust task queue for time-intensive operations. Web requests trigger quick responses, while expensive tasks (image processing, report generation, batch jobs) are processed asynchronously via Pub/Sub. Pull subscriptions with manual acknowledgment enable controlled processing with backpressure handling.
Best Practices
Message Ordering with Ordering Keys
Use ordering keys for use cases requiring guaranteed order. Messages with the same key are delivered sequentially, while different keys are processed in parallel. Ordering keys reduce throughput per key, so use a sufficient number of different keys for optimal performance.
Dead Letter Topics for Failed Messages
Configure dead letter topics for each subscription to isolate messages that cannot be processed after multiple attempts. Set max_delivery_attempts to a reasonable value and actively monitor dead letter topics.
Enable Exactly-Once Delivery
Enable exactly-once delivery for critical workloads where duplicates lead to inconsistencies (e.g., payment processing, inventory management). Note that this can cause higher latency and costs. For non-critical logs or metrics, at-least-once with idempotent consumers suffices.
Schema Evolution with Avro or Protocol Buffers
Define schemas for all topics and use schema validation. Plan schema evolution from the start: use optional fields, avoid breaking changes, and version schemas for major changes.
Choose Push vs. Pull Subscriptions Correctly
Use push subscriptions for event-triggered Cloud Functions or webhooks with low to medium load. Pull subscriptions are suitable for batch processing, controlled parallelization, and backpressure handling.
Optimize Message Retention and Storage Costs
Default retention is 7 days and can be extended; unacknowledged messages retained for more than 24 hours incur additional storage costs. Ensure subscriptions actively consume and acknowledge messages.
Monitoring with Cloud Monitoring and Alerting
Monitor key metrics: unacknowledged messages (backlog), oldest unacknowledged message age, subscription throughput, and dead letter topic size. Set alerts for abnormal values.
Google Cloud Pub/Sub Comparison
vs. AWS SNS/SQS: Pub/Sub unifies pub/sub and queue semantics in one service, while AWS uses separate services (SNS for fanout, SQS for queuing). Pub/Sub offers native ordering and exactly-once delivery options; AWS achieves similar results partly via FIFO queues.
vs. Azure Service Bus: Service Bus offers similar features (topics, queues, message sessions) but runs primarily in Azure regions. Both meet enterprise requirements; choice often depends on the preferred cloud provider.
vs. Apache Kafka / Managed Service for Apache Kafka: Kafka offers more control over partitioning, consumer groups, and log compaction, but requires cluster operation (self-hosted or as a managed service, e.g. Google Cloud Managed Service for Apache Kafka). Pub/Sub is fully serverless without cluster management, but is less suited to log compaction or very long message retention.
Integration with innFactory
As a certified Google Cloud partner, innFactory supports you in implementing event-driven architectures with Pub/Sub: from architecture consulting to migration of existing messaging systems (including migration off Pub/Sub Lite) to operations and cost optimization. We help with schema design, subscription configuration, monitoring setup, and integration with Dataflow, BigQuery, and other Google Cloud services.
Contact us for consulting on Google Cloud Pub/Sub and event streaming architectures.
Available Tiers & Options
Standard
- Fully managed, no cluster management
- Automatic scaling and global availability
- Synchronous replication across multiple zones
- Pricing varies by usage
Typical Use Cases
Frequently Asked Questions
What is Google Cloud Pub/Sub?
Google Cloud Pub/Sub is a fully managed messaging service for asynchronous communication and event streaming. The service supports exactly-once delivery, guaranteed message ordering, and direct BigQuery integration.
How does exactly-once delivery work in Pub/Sub?
Exactly-once delivery is achieved through a combination of client libraries and server-side deduplication. When enabled, Pub/Sub guarantees that each message is processed exactly once, even with retries, using unique message IDs and acknowledgment mechanisms.
What happened to Pub/Sub Lite?
Pub/Sub Lite was fully shut down on June 30, 2026. Google recommends existing users migrate to Pub/Sub Standard or to Google Cloud Managed Service for Apache Kafka, depending on the use case. For most scenarios, Pub/Sub Standard is the recommended choice.
How does Pub/Sub differ from Apache Kafka?
Pub/Sub is fully managed without cluster management, while Kafka requires self-operation (or use as a managed service such as Google Cloud Managed Service for Apache Kafka). Pub/Sub offers automatic scaling and global availability, while Kafka provides more control over partitioning, consumer groups, and log compaction.
What are BigQuery subscriptions?
BigQuery subscriptions allow direct streaming of Pub/Sub messages into BigQuery tables without additional ETL code. Pub/Sub automatically writes messages to defined BigQuery schemas, ideal for real-time analytics and data warehousing pipelines.
How does message ordering work in Pub/Sub?
Message ordering is achieved through ordering keys. Messages with the same ordering key are guaranteed to be delivered in the order they were published, which is important for scenarios like event sourcing or database change streams.
What message size limits apply to Pub/Sub?
The maximum message size is 10 MB per message, and the same limit applies to a single batch publish request. For larger payloads, store the data in Cloud Storage and transmit only the reference via Pub/Sub.
How is Pub/Sub billed?
Pub/Sub charges based on data volume (per GB), number of messages, and storage costs for unacknowledged messages retained for more than 24 hours. Exact prices are available on the official Google Cloud pricing page.
What are dead letter topics?
Dead letter topics are separate topics where messages are moved after multiple failed delivery attempts. This prevents faulty messages from blocking the subscription and enables separate error handling and monitoring.
How does schema validation work in Pub/Sub?
Pub/Sub supports schema validation with Avro and Protocol Buffers. Schemas are managed in a schema repository and validated on each publish, ensuring data quality and preventing faulty messages in downstream systems.
Is Pub/Sub GDPR compliant?
Pub/Sub is available in EU regions. Google Cloud offers data protection controls, compliance certifications, and data residency options; actual GDPR compliance depends on the chosen region, contractual basis, and configuration.
Note: All product information on this page has been compiled with care, but is provided without guarantee and may be outdated or incomplete. Cloud services evolve rapidly — features, pricing, SLAs, and availability change frequently. Authoritative and up-to-date information can only be found on the official product page of Google Cloud (official documentation). This page does not represent an offer by Google Cloud.
