0

We are experiencing a performance issue on Azure functions under load where there is a lag time between the call to the Azure function and the code in the function executing.

The first log entry for the Azure function call in Application insights says:

Function started (Id=6e2a7c0e-7190-4f4b-a146-9b957b49f4aa)

After that there is a random lag of a few seconds before the first log from our code which is the first line of code in our function.

We are only seeing this lag on load.

The Function App is running under an App Service plan with a premium pricing tier. The functions are all HTTP triggers.

Any ideas why this could be happening and what the "Function started" log means?

Vivek Ayer
  • 1,135
  • 11
  • 13

2 Answers2

1

This is a common "problem" known as cold start:

a cold start is an increase in latency for Functions which haven’t been called recently.

You can find a full explanation about it in here: https://azure.microsoft.com/en-au/blog/understanding-serverless-cold-start/

In case it's not accepted for your business, you should upgrade to premium plan where the instances are perpetually warmed. More info about it in here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • Hi Thiago, thanks for your answer. I wasn't aware of the new Premium plan introduced in April 2019. We are currently on a dedicated App service plan. The documentation you pointed out says "When using Azure Functions in the dedicated plan, the Functions host is always running, which means that cold start isn’t really an issue". The Function App is also configured to be "Always On". – Vivek Ayer Oct 24 '19 at 12:11
  • Always on is for the existing instances. If you need more (when scaling), you'll still have the cold start unless using Premium plan. – Thiago Custodio Oct 24 '19 at 14:03
0

It's a cold start like Thiago says, and if you thing startup time for a .NET app is bad, you should try a Node function!

To eliminate this you can set "Always On" to "On" by going to Configuration -> General Settings on the App Service in the portal. You need a Basic or higher tier in your App Service Plan, which it looks like you already have.

Derek Gusoff
  • 780
  • 4
  • 6