Pubsub Locational Endpoint - Resiliency

Hi all,
I’m trying to set up regional Pub/Sub using locational endpoints (e.g., us-central1-pubsub.googleapis.com) and was wondering if there’s any official documentation or best practices for configuring primary and fallback Pub/Sub endpoints. I haven’t been able to find clear guidance on this.

In my use case, Pub/Sub triggers a Cloud Run function, and since Cloud Run is regional, I have a primary and fallback deployment for cloud function (e.g., us-central1 and us-east1). My question is, If I configure Pub/Sub with a primary and fallback endpoint, will Pub/Sub automatically reroute to the fallback region in case of a failure in primary region?

Would appreciate any pointers or clarification. Thanks!

Hi Janey_Lin,

Google Cloud Pub/Sub topics and subscriptions are regional resources. While Pub/Sub offers high reliability within a region (across zones) and can deliver messages to the network-nearest subscriber, it does not automatically reroute your publishing requests to a fallback region if you are explicitly using a regional endpoint (e.g., us-central1-pubsub.googleapis.com) and that specific region experiences an outage.

Here are some suggestions that might help you achieve primary and fallback behavior for publishing:

  • Create Pub/Sub topics and subscriptions in your primary (e.g., us-central1) and fallback (e.g., us-east1) regions.
  • Your application should attempt to publish to the primary regional endpoint. If this fails due to a regional outage, it should then switch to publishing to the fallback regional endpoint. This requires monitoring, retry logic, and error handling in your publisher.
  • For push subscriptions, set up separate push subscriptions in each region, each pointing to its respective Cloud Run deployment. Pub/Sub will manage pushing messages to the active Cloud Run service in that region. If one Cloud Run service or its region becomes unhealthy, Pub/Sub will stop pushing messages to that subscription, but your publisher’s failover will ensure messages are sent to the active region’s topic.

You may also refer to the following documentation, that might help your use case: