Azure Face Throttling - inconsistent behaviour

Mark Otway 1 Reputation point
2021-07-30T10:36:14.413+00:00

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://learn.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
Azure Face
An Azure service that provides artificial intelligence algorithms that detect, recognize, and analyze human faces in images.
170 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mark Otway 1 Reputation point
    2021-07-30T21:41:24.393+00:00

    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.


  2. Michal Rubaj 0 Reputation points
    2023-04-05T12:59:33.1033333+00:00

    I'm getting the same issue as Mark did. Any updates on that?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.