Azure / Azure/azure-functions-host
Flex Consumption: maximumInstanceCount not enforced for HTTP triggers, host.json HTTP settings ignored
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 483
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
Bug Description
On the Flex Consumption plan, maximumInstanceCount is not enforced as a hard limit for HTTP trigger scaling. Additionally, host.json HTTP settings (maxConcurrentRequests, maxOutstandingRequests) are silently ignored.
When sending burst HTTP traffic that exceeds perInstanceConcurrency, the platform scales well beyond maximumInstanceCount, creating 30-60+ transient instances even when maximumInstanceCount is set to 1.
Configuration
// functionAppConfig.scaleAndConcurrency (via REST API / Azure CLI)
{
"alwaysReady": [{"instanceCount": 1, "name": "http"}],
"instanceMemoryMB": 2048,
"maximumInstanceCount": 1,
"triggers": {
"http": {
"perInstanceConcurrency": 200
}
}
}
// host.json
{
"version": "2.0",
"functionTimeout": "00:10:00",
"extensions": {
"http": {
"maxConcurrentRequests": 500,
"maxOutstandingRequests": 1000,
"dynamicThrottlesEnabled": false
}
}
}
Reproduction Steps
- Create a Flex Consumption function app (Python 3.10, ASGI/FastAPI)
- Set
maximumInstanceCount: 1,alwaysReady: 1,perInstanceConcurrency: 200 - Send 300+ concurrent HTTP requests using a simple load test script
- Query Application Insights:
requests
| where timestamp > ago(10m)
| summarize count() by cloud_RoleInstance
| order by count_ desc
- Observe 30+ unique
cloud_RoleInstancevalues, even thoughmaximumInstanceCountis1
Expected Behavior
- With
maximumInstanceCount: 1andperInstanceConcurrency: 200, requests beyond 200 concurrent should either queue or return HTTP 429 — not spin up additional instances. host.jsonHTTP settings (maxConcurrentRequests,maxOutstandingRequests) should be respected on Flex Consumption, or the documentation should clearly state they are ignored.
Actual Behavior
- 30-60+ unique
cloud_RoleInstanceIDs appear in Application Insights within minutes - Multiple instances handle requests simultaneously (not recycled workers — verified via per-second
dcount) host.jsonHTTP throttle settings have zero effect
Root Cause (Code Evidence)
In HttpOptionsSetup.cs, HTTP throttling defaults are only configured for Windows Consumption:
public void Configure(HttpOptions options)
{
if (_environment.IsWindowsConsumption()) // ← No Flex Consumption branch
{
options.DynamicThrottlesEnabled = true;
options.MaxConcurrentRequests = DefaultMaxConcurrentRequests;
options.MaxOutstandingRequests = DefaultMaxOutstandingRequests;
}
}
There is no IsFlexConsumptionSku() branch. On Flex Consumption, MaxConcurrentRequests and MaxOutstandingRequests default to DataflowBlockOptions.Unbounded, which means the HttpRequestQueue (source) is never enabled:
public static bool IsEnabled(HttpOptions httpOptions)
{
return httpOptions.MaxOutstandingRequests != DataflowBlockOptions.Unbounded ||
httpOptions.MaxConcurrentRequests != DataflowBlockOptions.Unbounded;
}
This means user-configured host.json values for HTTP throttling are parsed but overridden, and the worker host accepts unlimited concurrent requests. The external scale controller then sees high concurrency and scales out beyond maximumInstanceCount.
Documentation Gap
- The host.json HTTP settings docs list defaults for Consumption, Premium, and Dedicated — but do not mention Flex Consumption at all.
- The Flex Consumption deprecations table deprecates
FUNCTIONS_MAX_HTTP_CONCURRENCYbut does not mentionhost.jsonHTTP settings. - The event-driven scaling docs describe
maximumInstanceCountas a limit but don't clarify whether it's a hard or soft limit for HTTP triggers during bursts.
Questions
- Is
maximumInstanceCountintended to be a hard ceiling for HTTP triggers, or a soft target? - Should
host.jsonHTTP settings (maxConcurrentRequests,maxOutstandingRequests) be respected on Flex Consumption? - Are the 30+
cloud_RoleInstancevalues actual billable instances, or internal platform routing artifacts?
Environment
- Plan: Flex Consumption (SKU: FlexConsumption)
- Runtime: Python 3.10 (ASGI model with FastAPI)
- Region: East US
- Extension Bundle:
[4.*, 5.0.0)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/WebJobs.Script.WebHost/Configuration/HttpOptionsSetup.cs and HttpRequestQueue.cs, then reproduce the Flex Consumption behavior using the listed configuration and concurrent HTTP load. Check Application Insights for instance counts and compare the observed handling with the documented maximumInstanceCount and host.json HTTP settings. Done means the intended limit behavior is established and either the settings are enforced or the Flex Consumption documentation clearly explains their behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, fastapi, python
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100