azureazure-functions

Azure Function on consumption plan cold start can be up to 30 minutes


I have an azure function v3, written in C#, using the class library approach.

The problem is that cold starts can be as long as 30 minutes! I have consulted the documentation from this link

But there is no specific figures with regards to expected cold start timings.

An interesting observation is that if I navigate to the portal, and hit Refresh button:

enter image description here

Then the function gets immediately triggered.

  1. Is this normal, expected behavior?
  2. Could you please point me to any docs explicitly stating that ~0-30-50mins is OK for cold starts on Consumption Plan?

Solution

  • Consumption plan is what azure calls "serverless" model; what it means -

    your code reacts to events, effectively scales out to meet whatever load you’re seeing, scales down when code isn’t running, and you’re billed only for what you use.

    Cold start is nothing but the

    phenomenon that applications which haven’t been used take longer to start up.

    When you're using the Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events.

    If you've a "heavy-weight" code written and deployed on consumption plan which takes lot of memory and resources to get loaded to execute it may take more time such as your case. When you hit the refresh button from portal - The Functions runtime resets, and any required extensions are loaded onto the worker and gets loaded into the memory. That's why it reduces most of the latency.

    To understand more about the cold-start in azure serverless model & how you can minimize that please refer here - Understanding serverless cold start

    To reduce it more; you can have a warmup request which will hit based on time interval and you'll have your function always loaded in memory.