title | description | ms.assetid | ms.topic | ms.date | ms.custom |
---|---|---|---|---|---|
Azure Functions scale and hosting |
Learn how to choose between Azure Functions Consumption plan and Premium plan. |
5b63649c-ec7f-4564-b168-e0a74cb7e0f3 |
conceptual |
04/22/2022 |
H1Hack27Feb2017,devdivchpfy22 |
When you create a function app in Azure, you must choose a hosting plan for your app. There are three basic hosting plans available for Azure Functions: Consumption plan, Premium plan, and Dedicated (App Service) plan. All hosting plans are generally available (GA) on both Linux and Windows virtual machines.
The hosting plan you choose dictates the following behaviors:
- How your function app is scaled.
- The resources available to each function app instance.
- Support for advanced functionality, such as Azure Virtual Network connectivity.
This article provides a detailed comparison between the various hosting plans, along with Kubernetes-based hosting.
Note
If you choose to host your functions in a Kubernetes cluster, consider using an Azure Arc-enabled Kubernetes cluster. Hosting on an Azure Arc-enabled Kubernetes cluster is currently in preview. To learn more, see App Service, Functions, and Logic Apps on Azure Arc.
The following is a summary of the benefits of the three main hosting plans for Functions:
Plan | Benefits |
---|---|
Consumption plan | Scale automatically and only pay for compute resources when your functions are running. On the Consumption plan, instances of the Functions host are dynamically added and removed based on the number of incoming events. ✔ Default hosting plan. ✔ Pay only when your functions are running. ✔ Scales automatically, even during periods of high load. |
Premium plan | Automatically scales based on demand using pre-warmed workers, which run applications with no delay after being idle, runs on more powerful instances, and connects to virtual networks. Consider the Azure Functions Premium plan in the following situations: ✔ Your function apps run continuously, or nearly continuously. ✔ You have a high number of small executions and a high execution bill, but low GB seconds in the Consumption plan. ✔ You need more CPU or memory options than what is provided by the Consumption plan. ✔ Your code needs to run longer than the maximum execution time allowed on the Consumption plan. ✔ You require features that aren't available on the Consumption plan, such as virtual network connectivity. ✔ You want to provide a custom Linux image on which to run your functions. |
Dedicated plan | Run your functions within an App Service plan at regular App Service plan rates. Best for long-running scenarios where Durable Functions can't be used. Consider an App Service plan in the following situations: ✔ You have existing, underutilized VMs that are already running other App Service instances. ✔ Predictive scaling and costs are required. |
The comparison tables in this article also include the following hosting options, which provide the highest amount of control and isolation in which to run your function apps.
Hosting option | Details |
---|---|
ASE | App Service Environment (ASE) is an App Service feature that provides a fully isolated and dedicated environment for securely running App Service apps at high scale. ASEs are appropriate for application workloads that require: ✔ Very high scale. ✔ Full compute isolation and secure network access. ✔ High memory usage. |
Kubernetes (Direct or Azure Arc) |
Kubernetes provides a fully isolated and dedicated environment running on top of the Kubernetes platform. Kubernetes is appropriate for application workloads that require: ✔ Custom hardware requirements. ✔ Isolation and secure network access. ✔ Ability to run in hybrid or multi-cloud environment. ✔ Run alongside existing Kubernetes applications and services. |
The remaining tables in this article compare the plans on various features and behaviors. For a cost comparison between dynamic hosting plans (Consumption and Premium), see the Azure Functions pricing page. For pricing of the various Dedicated plan options, see the App Service pricing page.
The following table shows operating system and language support for the hosting plans.
Linux1,2 code-only |
Windows code-only | Linux1,2,3 Docker container |
|
---|---|---|---|
Consumption plan | C# JavaScript Java Python PowerShell Core TypeScript |
C# JavaScript Java PowerShell Core TypeScript |
No support |
Premium plan | C# JavaScript Java Python PowerShell Core TypeScript |
C# JavaScript Java PowerShell Core TypeScript |
C# JavaScript Java PowerShell Core Python TypeScript |
Dedicated plan | C# JavaScript Java Python TypeScript |
C# JavaScript Java PowerShell Core TypeScript |
C# JavaScript Java PowerShell Core Python TypeScript |
ASE | C# JavaScript Java Python TypeScript |
C# JavaScript Java PowerShell Core TypeScript |
C# JavaScript Java PowerShell Core Python TypeScript |
Kubernetes (direct) | n/a | n/a | C# JavaScript Java PowerShell Core Python TypeScript |
Azure Arc (Preview) | C# JavaScript Java Python TypeScript |
n/a | C# JavaScript Java PowerShell Core Python TypeScript |
1 Linux is the only supported operating system for the Python runtime stack.
2 PowerShell support on Linux is currently in preview.
3 Linux is the only supported operating system for Docker containers.
[!INCLUDE Timeout Duration section]
The following table compares the scaling behaviors of the various hosting plans.
Maximum instances are given on a per-function app (Consumption) or per-plan (Premium/Dedicated) basis, unless otherwise indicated.
Plan | Scale out | Max # instances |
---|---|---|
Consumption plan | Event driven. Scale out automatically, even during periods of high load. Azure Functions infrastructure scales CPU and memory resources by adding additional instances of the Functions host, based on the number of incoming trigger events. | Windows: 200 Linux: 1001 |
Premium plan | Event driven. Scale out automatically, even during periods of high load. Azure Functions infrastructure scales CPU and memory resources by adding additional instances of the Functions host, based on the number of events that its functions are triggered on. | Windows: 100 Linux: 20-1002 |
Dedicated plan3 | Manual/autoscale | 10-20 |
ASE3 | Manual/autoscale | 100 |
Kubernetes | Event-driven autoscale for Kubernetes clusters using KEDA. | Varies by cluster |
1 During scale-out, there's currently a limit of 500 instances per subscription per hour for Linux apps on a Consumption plan.
2 In some regions, Linux apps on a Premium plan can scale to 100 instances. For more information, see the Premium plan article.
3 For specific limits for the various App Service plan options, see the App Service plan limits.
Plan | Details |
---|---|
Consumption plan | Apps may scale to zero when idle, meaning some requests may have additional latency at startup. The consumption plan does have some optimizations to help decrease cold start time, including pulling from pre-warmed placeholder functions that already have the function host and language processes running. |
Premium plan | Perpetually warm instances to avoid any cold start. |
Dedicated plan | When running in a Dedicated plan, the Functions host can run continuously, which means that cold start isn't really an issue. |
ASE | When running in a Dedicated plan, the Functions host can run continuously, which means that cold start isn't really an issue. |
Kubernetes | Depending on KEDA configuration, apps can be configured to avoid a cold start. If configured to scale to zero, then a cold start is experienced for new events. |
[!INCLUDE functions-limits]
In some cases, when trying to create a new hosting plan for your function app in an existing resource group you may receive one of the following errors:
- The pricing tier is not allowed in this resource group
- <SKU_name> workers are not available in resource group <resource_group_name>
This can happen when the following conditions are met:
- You create a function app in an existing resource group that has ever contained another function app or web app.
- Your new function app is created in the same region as the previous app.
- The previous app is in some way incompatible with your new app. This can happen between SKUs, operating systems, or due to other platform-level features, such as availability zone support.
The reason this happens is due to how function app and web app plans are mapped to different pools of resources when being created. Different SKUs require a different set of infrastructure capabilities. When you create an app in a resource group, that resource group is mapped and assigned to a specific pool of resources. If you try to create another plan in that resource group and the mapped pool does not have the required resources, this error will occur.
When this error occurs, instead create your function app and hosting plan in a new resource group.
[!INCLUDE functions-networking-features]
Plan | Details |
---|---|
Consumption plan | Pay only for the time your functions run. Billing is based on number of executions, execution time, and memory used. |
Premium plan | Premium plan is based on the number of core seconds and memory used across needed and pre-warmed instances. At least one instance per plan must always be kept warm. This plan provides the most predictable pricing. |
Dedicated plan | You pay the same for function apps in an App Service Plan as you would for other App Service resources, like web apps. |
App Service Environment (ASE) | There's a flat monthly rate for an ASE that pays for the infrastructure and doesn't change with the size of the ASE. There's also a cost per App Service plan vCPU. All apps hosted in an ASE are in the Isolated pricing SKU. |
Kubernetes | You pay only the costs of your Kubernetes cluster; no additional billing for Functions. Your function app runs as an application workload on top of your cluster, just like a regular app. |