问题
What should I do when i encountered rate limit exceeded for face api other than using Task.Delay(1000)
?
I have about 50 records and detect/identify/verify in 2 seconds. For the identifyasync
, I set the confidence threshold to be 0.0f and the max number of candidates returned to be 50. I tried to use Task.Delay(1000)
and reduced the number of candidates, but it doesn't help to solve my problem.
Please give me advice on how to resolve this issue as i'm new to this.
回答1:
I wrote a library RateLimiter to handle this kind of constraints. It is composable, asynchroneous and cancellable.
Its seems that Face API quota limit of 10 calls per second, so you can write:
var timeconstraint = TimeLimiter.GetFromMaxCountByInterval(10, TimeSpan.FromSeconds(1));
for(int i=0; i<1000; i++)
{
await timeconstraint.Perform(DoFaceAPIRequest);
}
private Task DoFaceAPIRequest()
{
//send request to Face API
}
It is also available as a nuget package.
来源:https://stackoverflow.com/questions/49359508/rate-limit-exceeded-in-face-api