Markdown

Pub/Sub

Pub/Sub is the Acronym for Publish-Subscribe

A messaging pattern that decouples message producers from consumers. Publishers send messages to topics without needing to know which components will receive them. Subscribers express interest in one or more topics and receive messages without knowing the publishers' identity. This model supports asynchronous, many-to-many communication and is commonly contrasted with message queue-based and point-to-point messaging models.

Key Features of Google Cloud Pub/Sub

  • Publish-Subscribe Model: Publishers send messages to topics, and subscribers receive messages from those topics. Multiple subscribers can independently process messages.
  • Distributed and Scalable: Pub/Sub handles large message volumes and adapts to load changes without manual intervention.
  • Reliable and At-Least-Once Delivery: It ensures reliable message delivery using acknowledgments, delivering messages at least once.
  • Low Latency: Designed for low-latency message delivery, suitable for real-time applications and data processing.
  • Integration with Google Cloud Services: Seamlessly integrates with Cloud Functions, Dataflow, and BigQuery for event-driven applications and data pipelines.
  • Message Filtering: Supports filtering messages based on attributes, allowing subscribers to receive only messages that match specific criteria.
  • Dead Letter Queues: Includes Dead Letter Queues (DLQs) to handle messages that couldn't be successfully processed after multiple delivery attempts.
  • Global Availability: Available in multiple Google Cloud regions, providing global availability and redundancy.

Typical Use Cases

  • Real-time data analytics and processing
  • Event-driven microservices architecture
  • Decoupling components in a distributed system
  • Logging and monitoring
  • IoT (Internet of Things) data ingestion and processing
  • Building custom workflows and automation in response to events

Table: Messaging Models Comparison

ModelDescriptionUse Case
Publish-SubscribeDecoupled communication where publishers send messages to topics, and subscribers receive them.Event-driven systems, real-time data processing.
Message QueueProducers send messages directly to consumers.Task queues, workflow automation.
Point-to-PointDirect communication between a single producer and a single consumer.One-to-one messaging, request-response patterns.