In the previous articles in this series, we created a few functions and deployed them to Azure. In this article, we will review various options available for hosting our Function App in Azure.
When we create a Function App in Azure, we must specify where our functions are hosted and where they will run. This is done by selecting a hosting plan. Azure offers three basic hosting plans:
Consumption
Premium
Dedicated
Consumption plan
This is the default hosting plan and is truly serverless. The cost will depend on the amount of memory used and the number of executions of our functions. Resources used by all functions in a Function App are combined to calculate the cost.
Advantages
We pay only when our functions are running.
Azure will automatically scale our functions based on the load.
This plan offers a free monthly grant.
Note : Pricing calculation for this plan is somewhat complicated. Hence it is difficult to generalize free usage, but if we have a few hundred thousand function executions per month across all functions in our subscription, those will likely get covered under the free monthly grant.
Drawbacks
Cold starts - functions may scale down to zero and when the next invocation occurs, it will require some time to start up leading to a higher response time.
Maximum memory available per instance is 1.5 GB RAM
Premium plan
With the Premium plan, specific resource capacity (vCPU and memory) is reserved to run our functions. We can choose one of the available resource configurations. If autoscaling is enabled, Azure will spin up additional instances of the Function host based on load.
Advantages
Pre-warmed instances to avoid cold starts and provide consistent response times.
Predictable pricing as allocation of resources is determined upfront.
Drawbacks
- This plan can be expensive as you are paying for pre-allocated resources and also for additional instances for scaling.
Dedicated plan
If we have an existing App Service plan, we can use the Dedicated plan to run our functions. Our functions will run on our App Service. If the server hosting our App Service is underutilized, this plan can help us use the remaining resources well.
Advantages
Functions run on an existing App Service
No additional costs
Drawbacks
- Auto-scaling is not supported
In this article, we saw a quick overview of options available to host our Azure Functions. Note that this article covers only the basics. Pricing calculations and some finer details are beyond the scope of this article.
Top comments (0)