How to prevent ASP.NET applications to shut down when idle

How to prevent ASP.NET applications to shut down when idle

If you're an ASP.NET developer, chances are you might have experienced that the first request to your application takes much more time than subsequent ones. The reason being:

To save server resources, the ASP.NET application pool process shuts down in 20 minutes of idle time.

So if there are no requests to your applications in 20 minutes, the application pool will shut down.


This auto shutdown is good for you if you're a hosting provider and the application shares the infrastructure, but if you're not, that might hurt, because the first request will have to wake the process up, Initialize the application and then the server to the requests.


There are 2 approaches:

Turn this feature off

You can go to the application pools' advanced setting and set Idle Time-out to 0 which will mean, the application pool will never shut down due to no requests. This is good enough, but your Server Administrators will not agree on this so easily (Well, If they do, you've got a good team)

Suspend instead of shut down

Starting Windows Server 2012, there is a newer option to choose Idle Time-out Action to Suspend. According to Microsoft Docs:

A suspended worker process remains alive but is paged-out to disk, reducing the system resources it consumes. When a user accesses the site again, the worker process wakes up from suspension and is quickly available.

Suspend option sounds like a win-win for both Developers and Server Administrators.

Step by step instructions

Did you find this article valuable?

Support Satish Yadav by becoming a sponsor. Any amount is appreciated!