Cold Starts in Azure Functions

thumbnail for this post

This article describes Azure Functions running on Consumption Plan—the dynamically scaled and billed-per-execution compute service. Consumption Plan adds and removes instances dynamically. When a new instance handles its first request, the response time increases, which is called a cold start.

Learn more: Cold Starts in Serverless Functions.

When Does Cold Start Happen?

The very first cold start happens when the first request comes in after deployment.

After that request is processed, the instance stays alive for about 20 minutes to be reused for subsequent requests:

Probability of a cold start happening before minute X

Read more: When Does Cold Start Happen on Azure Functions?

How Slow Are Cold Starts?

The following chart shows the typical range of cold starts in Azure Functions V2, broken down per language. The darker ranges are the most common 67% of durations, and lighter ranges include 95%.

Typical cold start durations per language

A typical cold start latency spans from 2 to 15 seconds. C# functions usually complete the start within 3 seconds, while JavaScript and Java have longer tails.

View detailed distributions: Cold Start Duration per Language.

Is V2 Faster Than V1?

There are currently two generally available versions of Azure Functions runtime: V1 runs on top of .NET Framework 4.x, while V2 runs on .NET Core 2.x.

Even though .NET Core is supposed to be faster and more lightweight, Functions V2 still experience longer cold starts:

Comparison of cold start durations across runtime versions

The difference is especially noticeable for JavaScript functions.

Does Package Size Matter?

The above charts show the statistics for tiny “Hello World”-style functions. Adding dependencies and thus increasing the deployed package size will further increase the cold start durations.

The following chart compares three JavaScript functions with the various number of referenced NPM packages:

Comparison of cold start durations per deployment size (zipped)

Indeed, the functions with many dependencies can be several times slower to start.

Responses
Visit the Github Issue to comment on this page