Connection is reset when setting Virtual Memory Limit in IIS App pool

Chad 1 Reputation point
2021-05-25T17:17:32.423+00:00

It appears that setting the Virtual Memory limit on an IIS app pool will cause long running connections to reset after a random amount of time. I have an ASP.NET web api hosted in IIS (Windows Server 2019 Standard). Some async endpoints in the API take up to 5 min to return and they return a good amount of data (10MB). When I set the Virtual Memory Limit of the app pool to 4000000 (ie. 4GB), the connection will randomly get reset for long running requests. After watching the IIS worker process in task manager, I noticed consistent behavior across all 5 of our web servers.

Here's an example of the behavior causing the issue:

  1. When the async request comes in, the PID of the app pool is 21000
  2. After a random amount of time, lets say 20 seconds, a new IIS Worker Process is created for the same rest api with PID 2300 (I thought this was strange)
  3. The worker process with PID 2300 is killed after a random amount of time - say 1 min.
  4. After about another min, the original iis worker process with PID 21000 is killed and immediately causes the "Connection reset" error on the client.
  5. At the same time a new IIS worker process is created with PID 25000.

I can easily reproduce the above behavior on all 5 of our web servers (that are load balanced btw) by setting the Virtual Memory Limit on the api's app pool. When it's set to 0, the problem goes away.

Internet Information Services
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,455 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,121 Reputation points Microsoft Vendor
    2021-05-26T03:10:58.077+00:00

    Hi @Chad

    When the worker process exceeds the virtual memory limit, IIS will spin up a new worker process and kill the old one.

    I think this is why the connection is reset, and you set the Virtual Memory Limit to 0, which means there is no limit to the virtual memory it can use, so the problem goes away.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments