Azure / Azure/Azure-Functions

Thread count increases dramatically regardless of maxConcurrentRequests

Open
#1,008 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

Here is my simple http triggered function app.
Function1.cs
``` c#
public class Function1
{
[FunctionName(nameof(Function1))]
public static async Task RunAsync(
[HttpTrigger("POST")]string body,
[Queue("myqueue")]ICollector queue,
[Blob("mycontainer/{rand-guid}")]CloudBlockBlob cbc,
ILogger logger
)
{
try
{
logger.LogWarning(new EventId(-1, "FunctionStart"), $"{body?.Length}");

if (body != null)
{
try
{
await cbc.UploadTextAsync(body);
}
finally
{
queue.Add(cbc.Name);
}
}

logger.LogWarning(new EventId(-1, "FunctionEnd"), $"{body?.Length}");
}
catch (Exception gex)
{
logger.LogError(new EventId(-1, "FunctionError"), gex, body);
}
}
}
```

host.json
``` json
{
"version": "2.0",
"functionTimeout": "00:05:00",
"healthMonitor": {
"enabled": true,
"healthCheckInterval": "00:00:10",
"healthCheckWindow": "00:02:00",
"healthCheckThreshold": 6,
"counterThreshold": 0.80
},
"extensions": {
"http": {
// the maximum number of outstanding requests that will be held at any given time. The default is unbounded (-1).
"maxOutstandingRequests": -1,
// the maximum number of http functions that will be executed in parallel. The default is unbounded (-1).
"maxConcurrentRequests": 5,
// The default is false.
"dynamicThrottlesEnabled": true
}
}
}
```
In my opinion, the thread count should depend on the `maxConcurrentRequests` .
But it would go up to more than 300 even I had stopped creating new requests from JMeter. Then it took quite some time to decrease to 30 or so.
My VS2017 gave me the following information when I attached it to the process,
![image](https://user-images.githubusercontent.com/14272334/47505551-f0bbb300-d8a0-11e8-8f78-e4f7dcc01325.png)

Making the function Sync solves the problem on my local computer, but it still happens when I deploy the app onto the Azure.
Function1.cs
``` c#
public class Function1
{
[FunctionName(nameof(Function1))]
public static void Run(
[HttpTrigger("POST")]string body,
[Queue("myqueue")]ICollector queue,
[Blob("mycontainer/{rand-guid}")]CloudBlockBlob cbc,
ILogger logger
)
{
try
{
logger.LogWarning(new EventId(-1, "FunctionStart"), $"{body?.Length}");

if (body != null)
{
try
{
cbc.UploadTextAsync(body).Wait();
}
finally
{
queue.Add(cbc.Name);
}
}

logger.LogWarning(new EventId(-1, "FunctionEnd"), $"{body?.Length}");
}
catch (Exception gex)
{
logger.LogError(new EventId(-1, "FunctionError"), gex, body);
}
}
}
```

The same thing recurs after I replace the `await cbc.UploadTextAsync(body)` with `await Task.Delay(1000)`.
So, my question is : `maxConcurrentRequests` is not capable of limiting the thread count? How does it work exactly?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.