← Azure Functions memory calculator

How the Azure Functions calculator works

This page walks through how the Azure Functions calculator turns your usage data into an instance size. It starts from the peak side of the shared sizing model; this page covers what happens after that. Statements backed by Microsoft's documentation end with an Azure docs link to it. Choices the documentation doesn't make for us are explained and marked Assumption, which links to its row in the table of all of them.

01 Fixed instance sizes

Azure Functions doesn't take a free-form memory value. Flex Consumption, the recommended serverless plan, offers three instance sizes: Azure docs

Instance memoryCPU coresDefault HTTP concurrency
512 MB0.254
2,048 MB116
4,096 MB232

Python apps default to an HTTP concurrency of 1 at every size. Azure docs Each instance also gets 272 MB the platform keeps for system and host processes, which isn't billed. Your function code and the Functions host share the instance's resources. Azure docs

02 From peak usage to an instance size

memory = peak × (1 + limit margin)
size   = the smallest Flex Consumption size ≥ max(memory, 2,048 MB), else the smallest Elastic Premium SKU ≥ memory

Running out of memory recycles the instance, so, as with Lambda and Cloud Run, only the peak sets the size. The limit margin comes from the sensitivity, workload type and environment you choose; the sizing model explains it.

Microsoft writes the sizes in MB but measures memory in MB and MiB interchangeably, so the calculator compares MiB with those MB as equal; the sizes being powers of two point the same way. Assumption

Worked example

Peak 630 MiB, generic workload, medium sensitivity, production:

memory630 MiB × 1.30819 MiB
instance size512 is too small; 2,048 fits2048 MB
CPUfor that size1 core

A small function peaking at 50 MiB would fit 512 MB, but gets Microsoft's 2,048 MB default:

instance size50 MiB × 1.20 = 60 MiB; at least 2,048 MB2048 MB
CPUfor that size1 core

Lambda and Cloud Run also size from the peak alone: see the Lambda guide and the Cloud Run guide.

03 Microsoft's guidance: 2,048 MB and concurrency

Microsoft suggests 2,048 MB as the default for most apps, and 512 MB or 4,096 MB when concurrency or processing power call for it. Larger instances handle more concurrent executions, and CPU and network bandwidth grow with the size. Azure docs

So the calculator never goes below 2,048 MB: it picks the smallest size the measured peak fits in, from 2,048 MB up. 512 MB stays a choice you make by hand for a small, low-concurrency app, which then gets 0.25 cores and a default HTTP concurrency of 4; the note under the result says so. Assumption

Executions on an instance share its memory, so the measured peak includes the concurrency the app ran at. Raising concurrency, or moving to a size with a higher default, can need more memory per instance. Azure docs Assumption

04 Above 4,096 MB: Elastic Premium

SKUCoresMemory
EP113.5 GB
EP227 GB
EP3414 GB

Premium bills for the cores and memory provisioned, keeps at least one instance running, and every function app in the plan shares its instances. Azure docs EP1 never comes up, because Flex Consumption's 4,096 MB already covers it, and the calculator assumes your app is the only one on the plan. Assumption

memory5000 MiB × 1.306500 MiB
instance sizeabove 4,096 MB; EP2 holds 7,168 MiBEP2
CPUfor that SKU2 cores

The legacy Consumption plan runs every instance with up to 1.5 GB and has nothing to size. Azure docs

05 What the calculator writes

az functionapp scale config set --resource-group <resource-group> --name <app> --instance-memory 2048

functionAppConfig: {
  scaleAndConcurrency: {
    instanceMemoryMB: 2048
  }
}
  • az functionapp scale config set --instance-memory changes a Flex Consumption app's size at any time. Azure docs
  • In Bicep or ARM, functionAppConfig.scaleAndConcurrency.instanceMemoryMB sets the memory of each instance. Azure docs
  • For Premium, az functionapp plan update --sku EP2 changes the plan's SKU. Azure docs

06 Every warning, and why

Message aboutShown whenBasis
Too big for Flex Consumption warning The memory is above 4,096 MB Flex Consumption's largest size. Azure docs
Above every Premium SKU warning The memory is above EP3's 14 GB Premium's largest SKU. Azure docs
Peak below average error The peak you entered is lower than the average Impossible with real samples; it usually means two different series. See the sizing model.

07 Where the numbers come from

Azure Monitor's Memory working set (MemoryWorkingSet) is the memory the app uses now, and Average memory working set its average; both can be split by instance. They aren't available for Linux apps on the legacy Consumption plan. Azure docs Take the highest per-instance working set over a representative period as the peak.

08 All assumptions in one place

Besides the margins of the shared sizing model:

Our default: a value we chose. Our reading: how we read documentation that isn't explicit. About your setup: something we take for granted about your data or cluster.

AssumptionKindWhyIf it doesn't hold
Azure's MB are MiB ↩Our readingThe docs use MB and MiB for the same metrics; the sizes are powers of twoIf they were decimal, a peak just under a size would be about 5% too big for it.
Never below Microsoft's 2,048 MB default ↩Our defaultMicrosoft suggests it for most apps; 512 MB brings less CPU and concurrencyA small, low-concurrency app could run on 512 MB for less; set it by hand.
Concurrency stays as when the samples were taken ↩About your setupExecutions on an instance share its memoryMore concurrent executions per instance need more memory; size again after changing it.
The app is alone on its Premium plan ↩About your setupApps in a Premium plan share its instancesAdd up the peaks of every app in the plan before choosing a SKU.

Values you can change

The calculator’s Advanced: margins and defaults section, closed by default, lets you replace these values when your setup differs. Each field’s “?” says how it moves the result; a value outside the range is used at its nearest end, and “Reset to defaults” puts them all back.

ValueDefaultRangeWhere the default comes from
Limit marginfrom the profile0–200%MemoryLimit’s default, from sensitivity, workload type and environment (sizing model); sizes the memory the instance size must fit
Minimum instance size2,048 MB512, 2,048 or 4,096 MBMicrosoft’s suggestion for most apps, assumption 2; 512 MB suits a small, low-concurrency app

09 References

← Back to the Azure Functions calculator