I have the following code that I benchmark with jMeter and get about 3000 request per second on my localhost machine(the await
is missing intentionally to run synchronously):
public async Task<HttpResponseMessage> Get()
{
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent(Thread.CurrentThread.ManagedThreadId.ToString(), Encoding.UTF8, "text/plain");
return resp;
}
The problem is that when I pause the request for one second like below, for some reason the throughput is down to 10 requests per second for each w3wp.exe process (again the await
is missing intentionally to run synchronously):
public async Task<HttpResponseMessage> Get()
{
Task.Delay(1000).Wait();
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent(Thread.CurrentThread.ManagedThreadId.ToString(), Encoding.UTF8, "text/plain");
return resp;
}
Even when I do use await
there is no difference and the 10 requests per second does not improve at all:
public async Task<HttpResponseMessage> Get()
{
await Task.Delay(1000);
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent(Thread.CurrentThread.ManagedThreadId.ToString(), Encoding.UTF8, "text/plain");
return resp;
}
I tried all the config settings and nothing makes any change at all: `
web.config
<system.net>
<connectionManagement>
<add address="*" maxconnection="65400" />
</connectionManagement>
</system.net>
aspnet.config
<system.web>
<applicationPool
maxConcurrentThreadsPerCPU="100" />
</system.web>
machine.config
<processModel
autoConfig="false"
memoryLimit="70"
maxWorkerThreads="100"
maxIoThreads="100" />
The configs are set for both x86 and x64
I have 32 gigs of mem and 4 physical cores, Windows 10.
The CPU doesn't go over 10% load when benching the 10 requests per second.
The above code uses WEB API, but of course I reproduce the same results using a HTTP Handler.