My Asp.net core web application handles very few parallel requests

-1

I have a very small asp.net core 5 application running on IIS with only one controller. This controller is only doing a Thread.Sleep(3000) and nothing else. If I do more than ~70 parallel requests to this controller the whole web server freezes and does not respond to any requests for a minute. I know that doing blocking api calls like Thread.sleep is not a good idea, but still I'm very surprised that it can only handle up to 70 requests without failing like this.

My simple test code looks like this:

public class SleepController : Controller
{
    private readonly IMemoryCache _cache;
    private readonly IConfiguration _configuration;

    public SleepController(IMemoryCache memoryCache, IConfiguration configuration)
    {
        _configuration = configuration;
        _cache = memoryCache;
    }

    [HttpGet]
    public IActionResult Index()
    {
        var path = HttpContext.Request.Path.ToString();

        int sleepTime = 3000;

        int index = path.LastIndexOf('/');
        if (index > 0)
            sleepTime = int.Parse(path.Substring(index+1));
        Thread.Sleep(sleepTime);
        return new EmptyResult();
    }
}

Is there any settings in IIS or anything that I can adjust to make sure it can handle more parallel requests than this? I'm using the default IIS v10 settings.

Update: It was not clear in my original question that the problem is not only that it runs slow and have to wait for free threads, but a lot of the request actually fails (never respond) and I end up with this error message in the windows event log: An unhandled exception has occurred while executing the request. Exception: Microsoft.AspNetCore.Connections.ConnectionResetException: The client has disconnected ---> System.Runtime.InteropServices.COMException (0x80070040): The specified network name is no longer available. (0x80070040)

c#
asp.net
.net
asp.net-core
iis
asked on Stack Overflow Feb 25, 2021 by rgullhaug • edited Feb 25, 2021 by rgullhaug

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0