How can Consumption plan Azure Functions handle health checks?

Zachary Kingston 1 Reputation point
2023-02-06T21:24:54.4833333+00:00

I am investigating an issue where my Function app running on a Consumption plan is receiving HTTP requests as much as 20 seconds before the host is initialized, even when other hosts exist. My understanding is that for dedicated App Service Plans the Health Check system solves for this problem. But Health Checks are not supported by Consumption plans.

Is there a solution for this problem that is supported by consumption plans?

Note: My function app does not take 20 seconds to initialize. It's only about 2 seconds between the "Initializing Host" and the "Job Host Started" events. But it is being served HTTP requests that were made 18 seconds before the "Initializing Host" event.

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

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,666 Reputation points Microsoft Employee
    2023-02-08T05:16:23.6733333+00:00

    Hello @Zachary Kingston - AFAIK, with the Consumption SKU with which instances are dynamically added and removed, it's unlikely the front-end load balancer of the HTTP trigger has this issue specific to your unique environment.

    With that said, the 20-second delay on Consumption SKU sounds a lot like the Cold Start phenomenon. It can occur after your Functions App has been idle for about ~20min or during scale-to-zero when additional instances will have to be spun up, of which the former seems more consistent with your observation where the 20-second delay occurred even when other hosts exist.

    Should your investigation leads more toward Cold Start being the likely root cause, you can try to refactor your function to be more lightweight with minimal dependencies and leverage asynchronous execution wherever possible. For more context, please review the following blog post by the Functions team: Understanding serverless cold start

    Moreover, if your function is running a mission-critical requirement and you want to completely eliminate the Cold Start issue, you might consider switching to either the App Service Plan SKU with Always On setting toggled, or even better, Premium SKU through which the Warm-up feature is available.
    I hope this is helpful, please let me know if you have any further questions.