Azure / azure-cosmosdb-node

We recently announced deprecation of JS v1 SDK and this repo. Starting September 2020 Microsoft will not provide support for this library. Existing applications using library will continue to work as-is. We strongly recommend upgrading to @azure/cosmos library.
https://github.com/Azure/azure-sdk-for-js
MIT License
141 stars 108 forks source link

PreferredLocations ignored #228

Closed beneuto closed 6 years ago

beneuto commented 6 years ago

I have a Cosmos database replicated over 2 regions. Client is defined as below. However, no query is ever sent to Australia Southeast.

var connectionPolicy = new documentdb.DocumentBase.ConnectionPolicy();
connectionPolicy.PreferredLocations = ['Australia East', 'Australia Southeast'];
connectionPolicy.EnableEndpointDiscovery = true;

var client = new documentdb.DocumentClient(host, {masterKey: roKey}, connectionPolicy );
srinathnarayanan commented 6 years ago

Hi @beneuto. Couple of questions. Which operations are you running? Which are the read locations and which are the write locations, as configured for your account ?

beneuto commented 6 years ago

I am only using queryDocuments. Australia East is write and Australia Southeast is read.

beneuto commented 6 years ago

Incidentally, even after hard coding the url (e.g. mydb-australiasoutheast.documents.azure.com), all queries are still being directed to the write region. The application server is in the same region as the write region. Using a url such as the above in Power BI will result in the queries being sent to the read region. Power BI Service is located in the same region as the Cosmos read replica.

christopheranderson commented 6 years ago

(Sorry for the latency here)

You need to remove the write region from preferred regions. It will use any of the preferred regions. Remove Australia East and reads should go to Australia Southeast.

connectionPolicy.PreferredLocations = ['Australia Southeast'];
beneuto commented 6 years ago

That doesn't work. It still goes to the write region. Regardless, the aim is to balance load over both regions.

GustavoMoreiraPT commented 5 years ago

Hi @beneuto, @srinathnarayanan and @christopheranderson

Just saw your post. Did you find anything about this issue? I have a project where I am using Cosmos emulator for developing purposes. With EnableEndpointDiscovery set to true, after a first successful request, if I turn of the emulator, the request is taking 4/5 minutes before timing out. I need this property set to true in live environment. Is this only happening in the emulator? Thank you, Gustavo Moreira