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:
When the async request comes in, the PID of the app pool is 21000
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)
The worker process with PID 2300 is killed after a random amount of time - say 1 min.
After about another min, the original iis worker process with PID 21000 is killed and immediately causes the "Connection reset" error on the client.
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.