Azure functions host lifetime - consumption plan

Bo Eugen Gyring 21 Reputation points

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?


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

Accepted answer
  1. Luke Murray 10,521 Reputation points MVP

    The Azure functions default timeout is 5 minutes. -

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful