Pub/Sub Best Practices
Pub/Sub Best Practices: Subscribing
Publishing, subscribing, feature, latency, client-library, and testing trade-offs
Six 2023 episodes explain Pub/Sub trade-offs in batching, retries, ordering, flow control, retention, regional placement, and testing. Recommendations reflect the client libraries and service behavior discussed in that series.
Google Cloud Tech 2 of 6
In this collection Browse 6 summaries 2 of 6
Pub/Sub subscribers receive messages through a subscription attached to a topic. Chloe explains how to keep messages available, acknowledge completed work, and limit incoming work to what a subscriber can process.
Key points
- Prepare for delivery before publishing: Attach a subscription or enable topic retention before publishing messages that must remain available for later processing 00:00–01:04(opens in a new tab).
- Choose how the subscription delivers messages: The episode names pull, push, and BigQuery subscriptions as the available 2023 types and recommends choosing by delivery needs 00:00–02:09(opens in a new tab).
- Process before acknowledging: An acknowledgement tells Pub/Sub the message has been handled. Sending it before the work finishes can leave that work incomplete without a normal redelivery 01:04–02:09(opens in a new tab).
- Ordered redelivery can repeat later messages: In Chloe's example, a subscriber receives messages 1, 2, and 3 with the same ordering key. If message 2 is redelivered, message 3 is redelivered too, even if it was already acknowledged 01:04–03:13(opens in a new tab).
- Streaming pull needs a limit on outstanding work: A persistent connection receives messages continuously. Setting a maximum number of outstanding messages keeps a slow subscriber from holding more work than it can process while other subscribers have spare capacity 02:09–03:52(opens in a new tab).
Full video: https://www.youtube.com/watch?v=aHc-DOP43a8(opens in a new tab)