aatish bansal
aatish bansal

Reputation: 11

Is subscription lies in any region (like Topic) in Google Pub Sub

I am working on project which using google pub sub for transfer of messages, I have seen the Topic created in pub sub should specify regions (if we define multiple region, the message will store only nearby region of publisher). I have question regarding this.

  1. Is there is any replication in between regions for Topic for storing message.
  2. Is subscription also lies in any region which is created on Topic.

Upvotes: 0

Views: 2114

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17216

Cloud Pub/Sub is a global service. What that means is that topics and subscriptions are not tied to a specific region. Publishers can publish messages to topics in any region and subscribers can connect in any region (the same or different as the publishers) and receive the messages published to the topic via subscriptions.

The ability to specify regions for storage in Cloud Pub/Sub is a feature called message storage policy. The intention of this feature is to allow you specify which regions messages can or cannot be stored (though they still transit through other regions if subscribers are attached in those other regions). This allows one to place restrictions on data storage to, for example, comply with local laws.

If using the global Pub/Sub endpoint, publishers and subscriber connect to the network-nearest region to send or receive messages. When running publishers or subscribers on GCP, this means they will connect to the region where those resources are located. If using regional endpoints, then the publisher or subscriber connects to the region specified. However, even when using regional endpoints, the service is still global in that messages published in different regions to the same topic are still all available to subscribers using the same single subscription tied to that topic.

Messages are not replicated across regions when published. They are replicated to three zones within a region, though. If subscribers are located in a different region than the messages were published, then Cloud Pub/Sub routes messages across the regions to deliver them to the subscribers, wherever they are currently running.

Upvotes: 1

Related Questions