Change Feed in multi-region Azure Cosmos DB

2019-06-14 09:06发布

问题:

I am using Cosmos DB multi-region (single region write) account. Currently it is enabled in East US and West US. The write region is West US.

The Change Feed listeners are deployed in both East US and West US. I wanted to understand, if I can specify that the listeners deployed in East US reads Change Feed from East US and listeners in West US reads Change Feed from West US. Or all the listeners will always read Change Feed from write region?

回答1:

You can certainly make your listeners read from the closest region, which should improve your latency. You can use the PreferredLocations attribute to customize that:

var localPolicy = new ConnectionPolicy();
localPolicy.PreferredLocations.Add("East US");

// Builder initialization
.WithFeedCollection(new DocumentCollectionInfo()
{
    DatabaseName = DbName,
    Uri = new Uri(uri),
    CollectionName = feedCollection,
    MasterKey = key,
    ConnectionPolicy = localPolicy
})
.BuildAsync();