Azure functions host lifetime - consumption plan

Bo Eugen Gyring 21 Reputation points
2022-09-06T19:03:00.883+00:00

I have an Azure Function isolated process running on Azure and I am trying to understand the host lifetime (not the timeout). The general way of working, read in various blogs and tutorials, is that whenever an azure function receives a request for the first time, on the consumption plan, we face a cold start meaning the host needs to spin up - load the runtime and code in order to serve the request. Depending on your runtime (.Net, javascript etc) this cold start can vary but for .Net usually a few seconds (depending on what it needs to load of course) to serve the request. When we get past this cold start I get responses in the ranges of milliseconds. If the requests keep getting in the host instance is kept alive until requests no longer exists. Then the instance is shut down saving energy and costs which is good. What I do not understand is to keep this instance alive. Many blogs and tutorials mentions a host lifetime of 10 mins and it only requires 1 request to enable that 10 minutes lifetime but from my own tests this is certainly not the case. I have tested with standard and classic availablility test (hitting with 5 minutes intervals) and I see the host is shutdown and then reentering the cold start phase again. I even did a timetriggered azure function with a setting of every 2 minute to request the azure function and the result is the same. Can someone explain why I experience it this way?

Thx

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,679 questions
{count} votes

Accepted answer
  1. Luke Murray 10,896 Reputation points MVP
    2022-09-07T03:49:03.52+00:00

    The Azure functions default timeout is 5 minutes. https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale#timeout - https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout

    But you can adjust the host.json to be: 10 minutes.

    I wonder if the cold starts you are experiencing is when the Function App is scaling out a new instance, for each of your requests, instead of using the one currently existing.

    https://stackoverflow.com/questions/50732468/azure-functions-still-cold-start-in-consumption-plan-when-keep-alive-request-s

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful