Pub Sub Flashcards
What is Pub/Sub?
Pub/Sub is a fully-managed messaging system offered by GCP.
Do Pub/Sub servers run in all GCP regions around the world or just in specific regions?
Pub/Sub servers run in all GCP regions around the world.
What are the main differences between Pub/Sub and Pub/Sub Lite?
- Pub/Subs is global while Pub/Sub Lite is regional or zonal.
- Pub/Sub has more features and costs more and Pub/Sub Lite has less features but also costs less.
- Pub/Sub supports message-based parallelism and Pub/Sub Lite supports partition-based parallelism.
Generally speaking, what are the 3 components that make up Pub/Sub’s billing structure?
- Throughput
- Data transfer
- Storage data
Throughput is the amount of data published to a Topic or read from a subscription.
Data transfer is throughput that crosses a region. For example, a Publisher is in region A and the Subscriber is in region B.
Storage data are the messages retained by a Topic or acknowledged messages retained by a Subscription.
What is the main difference between Pub/Sub and Cloud Tasks?
Pub/Sub is designed so that publishers are unaware of subscribers and vice versa. With Cloud Tasks, the publishers are aware of the subscribers and have control over them.
Is Pub/Sub designed for end-user-to-service communication or service-to-service communication?
Pub/Sub is designed for service-to-service communication.
In general, what are the different stages of a message lifecycle?
- Publisher publishes a message to a Topic
- Pub/Sub stores the message in the nearest region to the publisher and replicates it across multiple zones
- Pub/Sub sends an ack to the Publisher
- Pub/Sub copies the message and delivers it to an attached Subscription
- Subscriber consumes the message from the Subscription and sends Pub/Sub an acknowledgement
- After at least one subscriber from each Subscription has acknowledged the message, Pub/Sub deletes it from storage.
When a subscriber pulls messages from a Subscription, it connects to the nearest Pub/Sub server which aggregates and prepares messages for delivery to the subscriber.
Does Google recommend using the same publisher client object to publish messages to a specific topic or creating a new publisher client object for each message that you want to publish?
Google recommends using the same publisher client object to publish messages to a specific topic so that time is not wasted establishing an authorized connection for each publishing request.
What is a Topic?
A topic is message feed.
By default, for how long will a Topic store messages and does it cost money?
By default, a Topic will not store any messages. However, a Topic can be configured to store messages for up to 31 days. Storing messages at the Topic level costs money but is the most economical since all attached Subscriptions will be able to access those messages without incurring storage costs of their own.
Can a Topic have multiple Subscriptions?
Yes. However, a Subscription can only be attached to a single Topic.
What are the 2 types of schema frameworks that Pub/Sub supports?
- Avro
- Protocol Buffers
Schemas are attached to a Topic.
What does a Subscription represent?
A Subscription represents an interest in receiving messages from a Topic. A Subscription is attached to a Topic.
By default, how long will a Subscription retain unacknowledged messages and does it cost money?
7 days, which is the maximum. Unacknowledged messages are free for the first 24 hours.
Can a Subscription be configured to retain acknowledged messages and does it cost money?
Yes, acknowledged messages can be retained for a maximum of 7 days. This feature is no free.
If a Subscription has multiple subscribers, how are messages allocated to those subscribers?
Each subscriber will receive a subset of the messages from the Subscription.
How does Pub/Sub minimize the possibility of delivering the same message to multiple subscribers?
While a subscriber is processing a message during the ack deadline, Pub/Sub tries not to deliver the message to other subscribers. Keep in mind, this is done on a best effort basis. If the possibility of duplications needs to be further reduced, think about enabling Exactly Once Delivery for the Subscription.