Coming from AWS Lambda function, I need to get a few newbie concepts clear about Azure Function.
Question set 1:
I created my first function, but I see in the portal that the function app is always running, why?
Does it cost money as long as the function app is running? Or only when a trigger invokes a function in the function app and the executing function starts to run?
In AWS Lambda, I am used to the fact that a function is only "running" when a trigger invokes it, and it is costing money as long as it is running.
Question set 2:
In Premium plan, I need to choose an App Service Plan and I chose the Elastic Premium EP1
It says: 210 total ACU, 3.5 GB Memory, 1 vCPU
I understand that to eliminate the cold start time, there is at least one such instance in the app service plan that is always running. So for this EP1, there is a basic minimum charge of about $180 / month.
Does it has to keep running 24/7?
Is there any way to turn off this always-running instance, during the night when users are not using my product, so that I can save some money?
Question 3:
Most importantly, how many parallel function executions can this instance run?
Say that once invoked, each task takes 5 minutes to complete, and there are 50 http triggers coming at the same time, invoking the function, can this EP1 instance handle without starting an extra instance?
2
Answers
Whether or not your function app is costing you depends on the tier which is deployed. The consumption plan is charged only per execution, the dedicated plans have a fixed cost, and the premium plan has a fixed base price.
Yes. That is correct. Unfortunately, there is no way to shut it down when not in use.
Based on your scenario, you would benefit from using Azure Container Apps which lets you run your own app as a container in a serverless environment and billed like the consumption plan for functions.
While this won’t directly improve cold starts as such, but if your application is quick to start with all the best practices in place, you should be good.
According to our discussion here
Depending on the volume of incoming events, an EP1 instance can execute a certain number of parallel functions. Similar to how the Consumption plan operates, instances of the Azure Functions host are dynamically added and withdrawn depending on the volume of incoming events. To avoid runaway executions, the run duration is set by default to 30 minutes, but you can change the host.json settings to make the duration unbounded for Premium plan apps.
host.json –
And Yes, The EP1 instance can support 50 concurrent http triggers that call the function without having to establish a second instance. Cause, Read this document carefully-github.com/MicrosoftDocs/… There’s already an always ready instance running in the premium plan that will be ready to run any incoming trigger. Thus Premium plan has an advantage of eliminating cold start in azure Functions. cold start is nothing but a delay in Functions trigger.