Forum Discussion
Cosmos Db JAVA SDK Retry Policy
nitinrahim `maxRetryWaitTime` in `ThrottlingRetryOptions` is an indicator of how long should the SDK wait before it stops retrying internally and returns the error back to the client. You can read about it in the Java docs on the `setMaxRetryWaitTime()` - ThrottlingRetryOptions (Azure SDK for Java Reference Documentation) (azuresdkdocs.blob.core.windows.net)
On the other hand, what you see in the diagnostics is the retry-after header, which is returned by the backend service to the client-side SDK as part of the internal retries to guide the client to retry after this time (usually in milliseconds and usually increases as multiples of 2) after throttling. Application or end user using SDK cannot control this internal header.
For concurrent requests, if you would like to keep retrying, you can increase the number of maxRetryAttempts, or you can also increase the maxRetryWaitTime so that the SDK will keep retrying. However, if throttling happens with multiple concurrent requests, then one way to resolve it is increasing the throughput of the database / container. Another way to solve this could be using the ThroughputControl mechanism built in the Java SDK, you can refer to the sample here - azure-cosmos-java-sql-api-samples/src/main/java/com/azure/cosmos/examples/throughputcontrol/async/ThroughputControlQuickstartAsync.java at main ยท Azure-Samples/azure-cosmos-java-sql-api-samples (github.com)
- nitinrahimJun 03, 2024Copper ContributorThanks Manish and Kushagra Thapar. Testing the same.
With Regards,
Nitin Rahim