Asynchronous messaging is quite popular as it helps participants on both sides of conversation to have the liberty to start, pause or resume conversation on their terms and eliminate the need for direct live connection. It is highly reliable and scalable and widely used in mobile phones, cloud-based applications such as Google cloud. Messaging and absorption for event-driven systems and streaming analytics have given push and popularity to this kind of messaging.
Today we look more in detail about two most popular and widely used asynchronous messaging services in real time on Google Cloud namely Pub / Sub and Pub / Sub Lite, understand their differences, use cases etc.
About Pub/ Sub
Cloud Pub/Sub is a real time messaging service offered by Google for applications to publish and subscribe to events. Messages can be published manually or watch the changes in Gmail using Gmail API and inform the user application on a real time basis.
Core components of Google Pub/Sub
- Topic – Publishers sent message to a named resource
- Publisher – an application that creates and sends a message to a Pub/Sub topic.
- Subscriber – Application that registers itself to a specific topic of interest in order to get proper message
- Subscription – represents a stream of messages from a single, specific topic, to be delivered to subscribing application
- Message – combination of data and other attributes which are sent by publisher to a topic and delivered to subscribers in the end
- Message attribute – A key value pair used by publisher to define a message
Features of Pub/Sub
- Fully managed asynchronous mail service highly reliable and scalable
- Quick exchange of messages
- Latencies on the order of 100 milliseconds
- Enables creation of event producers and consumers known as publishers and subscribers
- Offers at-least-once message delivery and best effort ordering to existing subscribers
- Message size upto 10 MB
- Lower cost option for high volume event ingestion
- Offers zonal storage and control over capacity management (users)
- Native data flow integration allows reliable, expressive, processing and integration of event streams in multiple languages such as Java, Python, and SQL.
How Pub/Sub works?
- The Publisher application creates a topic in the Publisher/Subscriber service and sends messages to the topic. The message comprises of payload and optional attributes describing the payload contents
- The services make sure that published messages are retained on behalf of subscriptions. Published message is retained till it is acknowledged by the subscriber
- Pub/Sub forward messages individually from topic to all its subscriptions
- Subscriber receive message either Pub/Sub pushing it or subscriber pull them from service
- Acknowledgment is sent by the subscriber to Pub/Sub for reach received message
- Service removes acknowledged messages from subscriber message queue
About Pub/Sub Lite
Pub/Sub Lite is a high-volume message service built to have low-cost operations by offering zonal storage and pre-provisioned features. Publishers send messages to Lite topics and subscribers receive messages from Lite subscriptions. Lite topics and Lite subscribers need to be in the same cloud project and they are zonal resources.
Comparison Table: Pub /Sub vs Pub/Sub Lite
Below table summarizes the difference between the two:
|Cloud Pub/Sub is a real time messaging service offered by Google for applications to publish and subscribe to events. Messages can be published manually or watch the changes in Gmail using Gmail API and inform user application on real time basis
|Pub/Sub Lite is a high-volume message service built to have low-cost operations by offering zonal storage and pre-provisioned feature
|Multi zone in single region (message replication)
It is automatically provisioned
You pay for the capacity you use
No limit on per topic storage
Retention period up to 7 days
Reach is global and regional
Resource namespace is global
Message routing is global
|Single zone supported (message replication)
It is provisioned before you use
You pay for the capacity you provision for
30 GiB-10 TiB per Lite topic storage
Service endpoints are regional
Resource namespace is zonal
Message routing is zonal
Download the comparison table: Pub/Sub vs Pub/Sub Lite
Pub/Sub Use Cases
- User interaction ingestion and server events
- Events distribution in real time
- Data replication among databases
- Parallel processing and workflows
- Data streaming for IoT devices
- Distributed cache refresh
- Load balancing to support reliability
ABOUT THE AUTHOR
I am here to share my knowledge and experience in the field of networking with the goal being – “The more you share, the more you learn.”
I am a biotechnologist by qualification and a Network Enthusiast by interest. I developed interest in networking being in the company of a passionate Network Professional, my husband.
I am a strong believer of the fact that “learning is a constant process of discovering yourself.”
– Rashmi Bhardwaj (Author/Editor)