Sunday, August 25, 2019

Azure Function hosting plans and scaling

 There are three hosting plans available for Azure Functions: Consumption planPremium plan, and App Service plan.
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 features, such as VNET connectivity.

Consumption Plan

Premium Plan

Dedicated Plan

When you're using the 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. 
When you're using the Premium plan, instances of the Azure Functions host are added and removed based on the number of incoming events just like the Consumption plan.
Your function apps can also run on the same dedicated VMs as other App Service apps (Basic, Standard, Premium, and Isolated SKUs).

With an App Service plan, you can manually scale out by adding more VM instances. You can also enable autoscale
The Consumption plan is the default hosting plan and offers the following benefits:
·       Pay only when your functions are running
·       Scale out automatically, even during periods of high load

Premium plan supports the following features:
·       Perpetually warm instances to avoid any cold start
·       VNet connectivity
·       Unlimited execution duration
·       Premium instance sizes (one core, two core, and four core instances)
·       More predictable pricing
·       High-density app allocation for plans with multiple function apps

Consider the Azure Functions premium plan in the following situations:
·       Your function apps run continuously, or nearly continuously.
·       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 are only available on a Premium plan, such as VNET/VPN connectivity.


Consider an App Service plan in the following situations:
·       You have existing, underutilized VMs that are already running other App Service instances.
·       You want to provide a custom image on which to run your functions.

On a Consumption plan, a function execution times out after a configurable period of time.
On a premium plan, code needs run longer than the maximum execution time allowed on the consumption plan.




Function app timeout duration

The timeout duration of a function app is defined by the functionTimeout property in the host.json project file. The following table shows the default and maximum values in minutes for both plans and in both runtime versions:
PlanRuntime VersionDefaultMaximum
Consumption1.x510
Consumption2.x510
App Service1.xUnlimitedUnlimited
App Service2.x30Unlimited

Always On

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.

How the consumption and premium plans work

In the consumption and premium plans, the 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. Each instance of the Functions host in the consumption plan is limited to 1.5 GB of memory and one CPU. An instance of the host is the entire 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. In the premium plan, your plan size will determine the available memory and CPU for all apps in that plan on that instance.
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.

Service limits

The following table indicates the limits that apply to function apps when running in the various hosting plans:
ResourceConsumption planPremium planApp Service plan1
Scale outEvent drivenEvent drivenManual/autoscale
Max instances2002010-20
Default time out duration (min)530302
Max time out duration(min)10unboundedunbounded3
Max outbound connections (per instance)600 active (1200 total)unboundedunbounded
Max request size (MB)4100100100
Max query string length4409640964096
Max request URL length4819281928192
ACU per instance100210-840100-840
Max memory (GB per instance)1.53.5-141.75-14
Function apps per plan100100unbounded5
App Service plans100 per region100 per resource group100 per resource group
Storage61 GB250 GB50-1000 GB
Custom domains per app5007500500
Custom domain SSL supportunbounded SNI SSL connection includedunbounded SNI SSL and 1 IP SSL connections includedunbounded SNI SSL and 1 IP SSL connections included
1 For specific limits for the various App Service plan options, see the App Service plan limits.
2 By default, the timeout for the Functions 1.x runtime in an App Service plan is unbounded.
3 Requires the App Service plan be set to Always On. Pay at standard rates.
4 These limits are set in the host.
5 The actual number of function apps that you can host depends on the activity of the apps, the size of the machine instances, and the corresponding resource utilization.
6 The storage limit is the total content size in temporary storage across all apps in the same App Service plan. Consumption plan uses Azure Files for temporary storage.
7 When your function app is hosted in a Consumption plan, only the CNAME option is supported. For function apps in a Premium plan or an App Service plan, you can map a custom domain using either a CNAME or an A record.

No comments:

Post a Comment