Reducing Cold Start Duration in Azure Functions
Note that I amended the format of the original chart: the range shows the most common 67% of values, and the dot shows the median value. This change makes the visual comparison easier for the rest of today’s post.
My numbers triggered several discussions on twitter. In one of them, Jeff Hollan (a program manager on Functions team) responded:
The numbers in @MikhailShilkov blog are significantly higher than what I see in our automated reports. I'm following up as well with @MikhailShilkov to validate all settings. But the rest of convo is valid :)— Jeff Hollan (@jeffhollan) February 26, 2019
The team collects the stats of cold starts internally, and their numbers were lower than mine. We started an e-mail thread to reconcile the results. I won’t publish any messages from the private thread, but I’m posting the main findings below.
Check the deployment method
For my tests, I’ve been using “Run from external package” deployment method, where the function deployment artifact is stored as a zip file on blob storage. This method is the most friendly for automation and infrastructure-as-code pipelines.
Apparently, it also increases the cold start duration. I believe the situation already improved since my original article, but here are the current numbers from mid-March.
Run-from-external-zip deployment increases the cold start by approximately 1 second.
I always configured my Function Apps to write telemetry to Application Insights. However, this adds a second to the cold start:
I can’t really recommend “Don’t use Application Insights” because the telemetry service is vital in most scenarios. Anyway, keep this fact in mind and watch the corresponding issue.
Keep bugging the team
While you can use the information above, the effect is still going to be limited. Obviously, the power to reduce the cold starts lies within the Azure Functions engineering team.
I consider this to be a part of my mission: spotlighting the issues in public gives that nudge to prioritize performance improvements over other backlog items.
Meanwhile, the data in Cold Starts in Azure Functions and Comparison of Cold Starts in Serverless Functions across AWS, Azure, and GCP are updated: I’m keeping them up-to-date as promised before.
Nice post and appreciate you circling back and helping keep us honest.— Jeff Hollan (@jeffhollan) March 27, 2019