question

MarkOtway-4437 avatar image
0 Votes"
MarkOtway-4437 asked MarkOtway-4437 edited

Azure Face Throttling - inconsistent behaviour

I'm using the Azure Face API, and have written a throttling class which will ensure I don't hit more than 20 transactions per minute.

My class basically provides a single proxy for FaceClient calls, and starts a timer when the first call is made. It counts the number of calls to the service, and when that number reaches 19, it sleeps for the remainder of the minute, at which point it resets the counter and timer, and the process starts again.

However, I'm seeing 'TooManyRequests' exceptions after just 12 calls to the service, which doesn't seem right.

In the Exception handler, if I see TooManyRequests, I sleep for another 5 seconds, and then retry. All of the exceptions I've seen have had a message in the response saying:

{"error":{"code":"429","message": "Requests to the PersonDirectory Person - Add Face Operation under Face API - v1.0-preview have exceeded rate limit of your current Face F0 pricing tier. Please retry after 1 second. To increase your rate limit switch to a paid tier."}}

However, despite saying "please retry after 1 second", if I retry the call after five seconds, I immediately see another TooManyRequests exception.

This inconsistent and unintelligible behaviour makes it really hard to avoid hitting the transaction limits. Is there any detailed information on how the transaction limits are counted/enforced, and what counts towards the transaction limits? There used to be a page in the docs, but things were rearranged sometime in the last couple of months, and now.

Per the documentation, it states that for operations not using million-scale tiers, "For all other operations, each API call will be counted as a transaction." This doesn't appear to tally with my experience of counting API calls, and seeing TooManyRequest exceptions before reaching 20 in one minute.

 https://azure.microsoft.com/en-us/pricing/details/cognitive-services/face-api/

That documentation states "Please refer to the documentation for the complete list and detailed descriptions of operations.", but the linked page:

 https://docs.microsoft.com/en-us/azure/cognitive-services/face/overview

does not have any such information on it and doesn't mention transactions at all.

Is it possible that the FaceClient .Net client is making multiple API calls per wrapper method? If so, how is it possible to track the number of transactions and throttle appropriately?


azure-face
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thanks for reaching out. For free tier, there's a limit of 20 transactions per min and 30,000 transactions per month. Can you please clarify, are you only getting this error after more than 12 transactions? Are you getting this error all the time or sometimes?

0 Votes 0 ·

1 Answer

MarkOtway-4437 avatar image
0 Votes"
MarkOtway-4437 answered MarkOtway-4437 edited

Yes, it happens after 12 transactions sometimes. It varies. The point is that the way I've structured the code guarantees I won't call any Face APIs more than 20 times in a 60-second period, and yet I'm still occasionally getting TooManyRequest errors.

That wouldn't be so bad, but when I get a TooManyRequest error, with a message saying "please retry after n seconds, my app sleeps for 2 x n seconds, retries the request, and it immediately fails with a TooManyRequests error, which literally makes no sense at all.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.