Hi @stringie,
I'm glad to hear that you were able to resolve the issue by using a requests.Session()
with keep-alive enabled. I apologize for the lack of this information in the official documentation; we appreciate your feedback and will make sure to pass it along for future improvements.
Thanks for sharing the information, which might be beneficial to other community members reading this thread as solution. Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", so I'll reiterate your response to an answer in case you'd like to accept the answer. This will help other users who may have a similar query find the solution more easily.
Query: Bizarre apparent throttling of the computer vision image analysis API.
Solution: I solved my own problem. Turns out that you need to use an HTTP Session with keep-alive enabled in order to not experience any delays. This is nowhere to be found in the Azure docs.
I was using Python's requests library directly to call the API, but what I had to do instead was build a requests.Session() object, which keeps the TCP connection alive for some time, while you send the subsequent requests using the session. Again, there is no mention of this in the docs for Image Analysis. They only show how to make a curl request, but they don't explain why your curl request my sometimes be 8 seconds long and sometimes 0.3 seconds long. The issue is the keep-alive connection.
Hopefully this will be useful to anyone who finds it, experiencing the same problem as me.
If you have any further questions or concerns, please don't hesitate to ask. We're always here to help.
Do click Accept Answer
and Yes
for was this answer helpful.