Pub/Sub Best Practices
Pub/Sub Best Practices: Patterns, Experimentation, and Testing
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 6 of 6
In this collection Browse 6 summaries 6 of 6
Chloe covers the operational choices around a Pub/Sub application: identifying resources and consumers, testing locally, and understanding what contributes to the bill.
Key points
- Use unique resource names: Deleting and recreating a resource under the same name can cause delays while cached information is stale. The episode also discourages high fan-out—attaching very many subscriptions—and cites a 10,000-subscription limit from 2023 00:00–01:04(opens in a new tab).
- Give independently managed subscribers separate credentials: This lets you track who consumes messages and control each consumer's access with Identity and Access Management (IAM) policies 00:00–02:10(opens in a new tab).
- Treat heartbeat messages as a proposed latency tactic: For streams that send little data but need prompt delivery, the 2023 episode suggests sending small extra messages to keep a topic active. It does not explain the service mechanism behind the suggestion 01:04–02:10(opens in a new tab).
- Test locally with the emulator: The Pub/Sub emulator runs a local version of the service for application development and testing through the Google Cloud CLI 01:04–02:10(opens in a new tab).
- Labels organize the bill: The episode says labels attached to resources are forwarded to billing, so charges can be broken down by label 01:04–03:19(opens in a new tab).
- Location and retention affect cost: It recommends consuming in or near the publish region to reduce network-egress charges. If one team manages both topic and subscription, and topic retention is longer, it suggests removing subscription retention to avoid that storage cost 02:10(opens in a new tab).
Full video: https://www.youtube.com/watch?v=pP6ipLkXnkk(opens in a new tab)