CosmosClientOptions.AvailabilityStrategy Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Availability Strategy to be used for periods of high latency
public Microsoft.Azure.Cosmos.AvailabilityStrategy AvailabilityStrategy { get; set; }
member this.AvailabilityStrategy : Microsoft.Azure.Cosmos.AvailabilityStrategy with get, set
Public Property AvailabilityStrategy As AvailabilityStrategy
Property Value
Examples
An example on how to set an availability strategy custom serializer.
CosmosClient client = new CosmosClientBuilder("connection string")
.WithApplicationPreferredRegions(
new List<string> { "East US", "Central US", "West US" } )
.WithAvailabilityStrategy(
AvailabilityStrategy.CrossRegionHedgingStrategy(
threshold: TimeSpan.FromMilliseconds(500),
thresholdStep: TimeSpan.FromMilliseconds(100)
))
.Build();
Remarks
The availability strategy in the example is a Cross Region Hedging Strategy. These strategies take two values, a threshold and a threshold step.When a request that is sent out takes longer than the threshold time, the SDK will hedge to the second region in the application preferred regions list. If a response from either the primary request or the first hedged request is not received after the threshold step time, the SDK will hedge to the third region and so on.