You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-scale.md
+44-26Lines changed: 44 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,79 +23,95 @@ ms.custom: H1Hack27Feb2017
23
23
---
24
24
# Azure Functions scale and hosting
25
25
26
-
You can run Azure Functions in two different modes: Consumption plan and Azure App Service plan. The Consumption plan automatically allocates compute power when your code is running, scales out as necessary to handle load, and then scales down when code is not running. You don't have to pay for idle VMs and don't have to reserve capacity in advance. This article focuses on the Consumption plan, a [serverless](https://azure.microsoft.com/overview/serverless-computing/) app model. For details about how the App Service plan works, see the [Azure App Service plans in-depth overview](../app-service/azure-web-sites-web-hosting-plans-in-depth-overview.md).
26
+
Azure Functions runs in two different modes: Consumption plan and Azure App Service plan. The Consumption plan automatically allocates compute power when your code is running. Your app is scaled out when needed to handle load, and scaled down when code is not running. You don't have to pay for idle VMs or reserve capacity in advance. This article focuses on the Consumption plan, a [serverless](https://azure.microsoft.com/overview/serverless-computing/) app model. For details about how the dedicated App Service plan works, see the [Azure App Service plans in-depth overview](../app-service/azure-web-sites-web-hosting-plans-in-depth-overview.md).
27
27
28
-
>[!NOTE]
28
+
>[!NOTE]
29
29
> [Linux hosting](functions-create-first-azure-function-azure-cli-linux.md) is currently only available on an App Service plan.
30
30
31
31
If you aren't familiar with Azure Functions, see the [Azure Functions overview](functions-overview.md).
32
32
33
-
When you create a function app, you must configure a hosting plan for functions that the app contains. In either mode, an instance of the *Azure Functions host* executes the functions. The type of plan controls:
33
+
When you create a function app, you choose the hosting plan for functions in the app. In either plan, an instance of the *Azure Functions host* executes the functions. The type of plan controls:
34
34
35
35
* How host instances are scaled out.
36
36
* The resources that are available to each host.
37
37
38
-
Currently, you must choose the type of hosting plan during the creation of the function app. You can't change it afterward.
38
+
> [!IMPORTANT]
39
+
> You must choose the type of hosting plan during the creation of the function app. You can't change it afterward.
39
40
40
-
On an App Service plan you can scale between tiers to allocate different amount of resources. On the Consumption plan, Azure Functions automatically handles all resource allocation.
41
+
On an App Service plan, you can scale between tiers to allocate different amount of resources. On the Consumption plan, Azure Functions automatically handles all resource allocation.
41
42
42
43
## Consumption plan
43
44
44
-
When you're using a Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events. This plan scales automatically, and you are charged for compute resources only when your functions are running. On a Consumption plan, a function execution times out after a configurable period of time.
45
+
When you're using a Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events. This serverless plan scales automatically, and you're charged for compute resources only when your functions are running. On a Consumption plan, a function execution times out after a configurable period of time.
45
46
46
47
> [!NOTE]
47
48
> The default timeout for functions on a Consumption plan is 5 minutes. The value can be increased for the Function App up to a maximum of 10 minutes by changing the property `functionTimeout` in the [host.json](functions-host-json.md#functiontimeout) project file.
48
49
49
50
Billing is based on number of executions, execution time, and memory used. Billing is aggregated across all functions within a function app. For more information, see the [Azure Functions pricing page].
50
51
51
52
The Consumption plan is the default hosting plan and offers the following benefits:
52
-
- Pay only when your functions are running.
53
-
- Scale out automatically, even during periods of high load.
53
+
54
+
* Pay only when your functions are running.
55
+
* Scale out automatically, even during periods of high load.
54
56
55
57
## App Service plan
56
58
57
-
In the App Service plan, your function apps run on dedicated VMs on Basic, Standard, Premium, and Isolated SKUs, similar to Web Apps, API Apps, and Mobile Apps. Dedicated VMs are allocated to your App Service apps, which means the functions host is always running. App Service plans support Linux.
59
+
In the dedicated App Service plan, your function apps run on dedicated VMs on Basic, Standard, Premium, and Isolated SKUs, which is the same as other App Service apps. Dedicated VMs are allocated to your function app, which means the functions host can be [always running](#always-on). App Service plans support Linux.
58
60
59
61
Consider an App Service plan in the following cases:
60
-
- You have existing, underutilized VMs that are already running other App Service instances.
61
-
- You expect your function apps to run continuously, or nearly continuously. In this case, an App Service Plan can be more cost-effective.
62
-
- You need more CPU or memory options than what is provided on the Consumption plan.
63
-
- You need to run longer than the maximum execution time allowed on the Consumption plan (of 10 minutes).
64
-
- You require features that are only available on an App Service plan, such as support for App Service Environment, VNET/VPN connectivity, and larger VM sizes.
65
-
- You want to run your function app on Linux, or you want to provide a custom image on which to run your functions.
62
+
63
+
* You have existing, underutilized VMs that are already running other App Service instances.
64
+
* Your function apps run continuously, or nearly continuously. In this case, an App Service Plan can be more cost-effective.
65
+
* You need more CPU or memory options than what is provided on the Consumption plan.
66
+
* Your code needs to run longer than the maximum execution time allowed on the Consumption plan, which is up to 10 minutes.
67
+
* You require features that are only available on an App Service plan, such as support for App Service Environment, VNET/VPN connectivity, and larger VM sizes.
68
+
* You want to run your function app on Linux, or you want to provide a custom image on which to run your functions.
66
69
67
70
A VM decouples cost from number of executions, execution time, and memory used. As a result, you won't pay more than the cost of the VM instance that you allocate. For details about how the App Service plan works, see the [Azure App Service plans in-depth overview](../app-service/azure-web-sites-web-hosting-plans-in-depth-overview.md).
68
71
69
-
With an App Service plan, you can manually scale out by adding more VM instances, or you can enable autoscale. For more information, see [Scale instance count manually or automatically](../monitoring-and-diagnostics/insights-how-to-scale.md?toc=%2fazure%2fapp-service-web%2ftoc.json). You can also scale up by choosing a different App Service plan. For more information, see [Scale up an app in Azure](../app-service/web-sites-scale.md).
72
+
With an App Service plan, you can manually scale out by adding more VM instances, or you can enable autoscale. For more information, see [Scale instance count manually or automatically](../monitoring-and-diagnostics/monitoring-autoscale-get-started.md?toc=%2fazure%2fapp-service%2ftoc.json). You can also scale up by choosing a different App Service plan. For more information, see [Scale up an app in Azure](../app-service/web-sites-scale.md).
70
73
71
-
If you are planning to run JavaScript functions on an App Service plan, you should choose a plan that has fewer vCPUs. For more information, see the [Choose single-core App Service plans](functions-reference-node.md#considerations-for-javascript-functions).
74
+
When running JavaScript functions on an App Service plan, you should choose a plan that has fewer vCPUs. For more information, see the [Choose single-core App Service plans](functions-reference-node.md#considerations-for-javascript-functions).
72
75
73
76
<!-- Note: the portal links to this section via fwlink https://go.microsoft.com/fwlink/?linkid=830855 -->
74
77
<aname="always-on"></a>
75
78
### Always On
76
79
77
-
If you run on an App Service plan, you should enable the **Always On** setting so that your function app runs correctly. On an App Service plan, the functions runtime will go idle after a few minutes of inactivity, so only HTTP triggers will "wake up" your functions. This is similar to how WebJobs must have Always On enabled.
80
+
If you run on an App Service plan, you should enable the **Always on** setting so that your function app runs correctly. On an App Service plan, the functions runtime goes idle after a few minutes of inactivity, so only HTTP triggers will "wake up" your functions. Always on is available only on an App Service plan. On a Consumption plan, the platform activates function apps automatically.
81
+
82
+
## What is my hosting plan
83
+
84
+
To determine the hosting plan used by your function app, see **App Service plan / pricing tier** in the **Overview** tab for the function app in the [Azure portal](https://portal.azure.com). For App Service plans, the pricing tier is also indicated.
85
+
86
+

78
87
79
-
Always On is available only on an App Service plan. On a Consumption plan, the platform activates function apps automatically.
88
+
You can also use the Azure CLI to determine the plan, as follows:
az appservice plan list --query "[?id=='$appServicePlanId'].sku.tier" --output tsv
93
+
```
94
+
95
+
When the output from this command is `dynamic`, your function app is in the Consumption plan. All other values indicate tiers of an App Service plan.
80
96
81
97
Even with Always On enabled, the execution timeout for individual functions is controlled by the `functionTimeout` setting in the [host.json](functions-host-json.md#functiontimeout) project file.
82
98
83
99
## Storage account requirements
84
100
85
-
On either a Consumption plan or an App Service plan, a function app requires a general Azure Storage account that supports Azure Blob, Queue, Files, and Table storage. Internally, Azure Functions uses Azure Storage for operations such as managing triggers and logging function executions. Some storage accounts do not support queues and tables, such as blob-only storage accounts (including premium storage) and general-purpose storage accounts with zone-redundant storage replication. These accounts are filtered from the **Storage Account**blade when you're creating a function app.
101
+
On either a Consumption plan or an App Service plan, a function app requires a general Azure Storage account, which supports Azure Blob, Queue, Files, and Table storage. This is because Functions relies on Azure Storage for operations such as managing triggers and logging function executions, but some storage accounts do not support queues and tables. These accounts, which include blob-only storage accounts (including premium storage) and general-purpose storage accounts with zone-redundant storage replication, are filtered-out from your existing **Storage Account**selections when you create a function app.
86
102
87
-
<!-- JH: Does using a PRemium Storage account improve perf? -->
103
+
<!-- JH: Does using a Premium Storage account improve perf? -->
88
104
89
105
To learn more about storage account types, see [Introducing the Azure Storage services](../storage/common/storage-introduction.md#azure-storage-services).
90
106
91
107
## How the Consumption plan works
92
108
93
-
In the Consumption plan, the scale controller automatically 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. Each instance of the Functions host is limited to 1.5 GB of memory. An instance of the host is the function app, meaning all functions within a function app share resources within an instance and scale at the same time. Function apps that share the same Consumption plan are scaled independently.
109
+
In the Consumption plan, the scale controller automatically 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. Each instance of the Functions host is limited to 1.5 GB of memory. An instance of the host is the function app, meaning all functions within a function app share resource within an instance and scale at the same time. Function apps that share the same Consumption plan are scaled independently.
94
110
95
111
When you use the Consumption hosting plan, function code files are stored on Azure Files shares on the function's main storage account. When you delete the main storage account of the function app, the function code files are deleted and cannot be recovered.
96
112
97
113
> [!NOTE]
98
-
> When you're using a blob trigger on a Consumption plan, there can be up to a 10-minute delay in processing new blobs if a function app has gone idle. After the function app is running, blobs are processed immediately. To avoid this cold-start delay, use an App Service plan with Always On enabled, or use the Event Grid trigger. For more information, see [the blob trigger binding reference article](functions-bindings-storage-blob.md#trigger).
114
+
> When you're using a blob trigger on a Consumption plan, there can be up to a 10-minute delay in processing new blobs. This delay occurs when a function app has gone idle. After the function app is running, blobs are processed immediately. To avoid this cold-start delay, use an App Service plan with **Always On** enabled, or use the Event Grid trigger. For more information, see [the blob trigger binding reference article](functions-bindings-storage-blob.md#trigger).
99
115
100
116
### Runtime scaling
101
117
@@ -108,7 +124,8 @@ The unit of scale is the function app. When the function app is scaled out, addi
108
124
### Understanding scaling behaviors
109
125
110
126
Scaling can vary on a number of factors, and scale differently based on the trigger and language selected. However there are a few aspects of scaling that exist in the system today:
111
-
* A single function app will only scale to a maximum of 200 instances. A single instance may process more than one message or request at a time though, so there isn't a set limit on number of concurrent executions.
127
+
128
+
* A single function app only scales up to a maximum of 200 instances. A single instance may process more than one message or request at a time though, so there isn't a set limit on number of concurrent executions.
112
129
* New instances will only be allocated at most once every 10 seconds.
113
130
114
131
Different triggers may also have different scaling limits as well as documented below:
@@ -117,11 +134,12 @@ Different triggers may also have different scaling limits as well as documented
117
134
118
135
### Best practices and patterns for scalable apps
119
136
120
-
There are many aspects of a function app that will impact how well it will scale, including host configuration, runtime footprint, and resource efficiency. View the [scalability section of the performance considerations article](functions-best-practices.md#scalability-best-practices) for more information.
137
+
There are many aspects of a function app that will impact how well it will scale, including host configuration, runtime footprint, and resource efficiency. For more information, see the [scalability section of the performance considerations article](functions-best-practices.md#scalability-best-practices). You should also be aware of how connections behave as your function app scales. For more information, see [How to manage connections in Azure Functions](manage-connections.md).
121
138
122
139
### Billing model
123
140
124
-
Billing for the Consumption plan is described in detail on the [Azure Functions pricing page]. Usage is aggregated at the function app level and counts only the time that function code is executed. The following are units for billing:
141
+
Billing for the Consumption plan is described in detail on the [Azure Functions pricing page]. Usage is aggregated at the function app level and counts only the time that function code is executed. The following are units for billing:
142
+
125
143
***Resource consumption in gigabyte-seconds (GB-s)**. Computed as a combination of memory size and execution time for all functions within a function app.
126
144
***Executions**. Counted each time a function is executed in response to an event trigger.
0 commit comments