Share via

Cold start for AnalyzeDocumentAsync prebuilt-receipt

Fabrice Bellenand 0 Reputation points
2024-10-29T14:35:59.91+00:00

Hi all,

In an .net framework 4.8 console app, I use the code below (from Azure samples), with a S0 pricing tier, location in France.

Each time I run the app, the first call to AnalyzeDocumentAsync takes around 20 seconds, as if there was a cold start or something. Then if I let the app opened, and call several time the same code, it takes around 3 seconds, even if I change the image to analyse.
And if I wait around 1 minute before calling again the code, or if I close and reopen the app, it takes again around 20 seconds.

Is this a normal behavior ? I guess not as it would not be usable in a production mode...

Do I miss something ? An azure configuration maybe ?

I also tried to use the beta Azure.AI.DocumentIntelligence rather than Azure.AI.FormRecognizer.DocumentAnalysis, but the behavior is exactly the same.

var stream = System.IO.File.OpenRead(@"D:\test.jpg");

var credential = new AzureKeyCredential(apiKeyAI);

var client = new DocumentAnalysisClient(new Uri(endpointAI), credential);

AnalyzeDocumentOperation operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-receipt", stream);

Azure.AI.FormRecognizer.DocumentAnalysis.AnalyzeResult receipts = operation.Value;

Thanks for any help !

Azure Document Intelligence in Foundry Tools
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Azar 31,720 Reputation points MVP Volunteer Moderator
    2025-01-14T18:56:05.0633333+00:00

    Hi there Fabrice Bellenand

    Thnx for using QandA platform

    i guess this us common in the S0 pricing tier as resources are dynamically allocated when a request is made after a period of inactivity. requests within a short timeframe perform faster because the resources remain warm. but, after a minute of inactivity, the resources are deallocated, causing the next request to reinitialize.

    you can use a periodic "keep-alive" call to prevent this, Upgrade to the S1 tier, which offers more consistent performance and lower latency, If low latency is critical for your production, consider upgrading to a higher tier or implementing a keep-alive mechanism.

    If this helps kindlyy accept the answer thnx much

    Was this answer helpful?

    0 comments No comments

Your answer

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