user22323640
user22323640

Reputation: 1

Is it possible to identify Rate Limit Exceedance in CosmosDB for MongoDB Using the Standard MongoDB SDK?

We are using standard mongodb SDK to access CosmosDB for MongoDB. Sometimes it reaches the rate limit and reject many requests. We need to identify this scenario and stop sending documents for a while.

Azure doc says it is going to return 16500 / 429 response in this case. However we're using the standard mongodb sdk so looks like no way to get the http status code. And according to this page: https://devblogs.microsoft.com/cosmosdb/upgrade-your-server-version-from-3-2-to-3-6-for-azure-cosmos-db-api-for-mongodb/ even cosmosdb's sdk won't return special code after 3.6?

Let me know if you have the solution for this.

Thanks!

Our test shows it would throw a MongoExecutionTimeoutException with message like: Request timed out. Retries due to rate limiting: True. in this scenario but not sure if this is the right way.

Upvotes: 0

Views: 101

Answers (1)

user22323640
user22323640

Reputation: 1

thanks for checking this question.

We've fixed the issue in another way. Our current code has some issue and triggered rate limit when trying to create a collection but it is not required anymore. After it is fixed, we never get timeout exceptions.

From what I can tell, when the SSR is enabled, you only get Timeout exception. However as mentioned in the question, for DML operation like creating a collection, the error message is different when rate limit is reached. As the SSR is always enabled on the server, we have no chance to test what error code is going to be returned when SSR is disabled.

Upvotes: 0

Related Questions