IISRESET vs Recycling Application Pools
I think most IIS administrators know IISRESET command, and why they use it. One of possible reasons can be to restart IIS services to initialize web applications, or to apply some changes of applications & IIS settings.
Now, I hope you to doubt efficiency of this operation, by asking a question – ‘Is this necessary?’ or, ‘Is this the best way to achieve what I want?’
you may want to use ‘recycling’ feature in IIS, rather than IISRESET, after reading this. More importantly, you will find more details & practical information for both important IIS operations.
FYI, I’m going to use screen shots from IIS6 & Windows2003. But the information of this article can be applied for IIS7.x.
A concern – do you run IISRESET frequently?
There’re just a few conditions those need your IISRESET command. In most situations, you don’t need this. I have a concern if you always run this command for applying any changes, or release system resource – memory – regularly, or frequently. Because it’s much more cost than what you really need to take – there’re side effects. So, I’d like you to review this article to find out the differences of commands, actual effects, and better operations you can do.
A suggestion – do you understand what ‘Recycling’ is for?
‘Recycling AppPool’ has been introduced from IIS6 in Windows2003. It’s designed to restart only application pools(=worker processes). It can be done in a command prompt(run ‘IISAPP /?’ in a command prompt for details), as well as in the IIS manager. By the way, this article seems that I’m about to recommend you to use recycling instead of IISRESET command… yes I am.
Then, what IISRESET does?
When you run IISRESET, many things will happen. In order to understand them, I think I need to show you how IIS looks like – about IIS core components. The below shows you roles of each IIS component, and take a note that the roles will be stopped during IISRESET.
A brief overview of IIS Architecture
IIS has 3 main components – http.sys, IIS admin Services, and worker processes (=Application Pools).
This is a kernel component, which means it’s not a part of user mode processes, such as W3WP.EXE. A kernel component never uses any virtual memory addresses of user processes. It’s isolated & separated. HTTP.SYS has 3 important roles – (client) connection management, routing requests from browsers, and managing response cache.
: Routing requests means http.sys dispatches requests to the correct ‘Application Pool Queue’ for each worker process.
2. Worker Processes (=Application Pools, w3wp.exe)
W3WP(WWW Worker Process) handles all the contents, aka, static contents, such as HTML/GIF/JPG files, and runs dynamic contents, such as ASP/ASP.NET applications. Therefore, the status of W3WP process(=Application Pool) is critical for the performance & stability of web applications, or web sites.
3. IIS Admin Services
Managing the above IIS components using IIS configurations as a Windows Service Management(SVCHost.exe).
The way how IISRESET works
When IISRESET command runs, it stops all IIS services with its components. Basically, ‘stopping, and starting all IIS related services’ can explain almost. But we still need to see its first step – stopping all IIS components(services). In fact, it does not kill any worker processes, and running components. Like any Windows Services, the command just sends a message – ‘Stop running as soon as possible’ – to shutdown IIS services gracefully.
Let’s say a worker process (an application pool = w3wp.exe) has an application running inside. After receiving the message, it doesn’t stop currently running applications, instead, it continues running to finish existing applications, and can’t have any more application requests, because HTTP.SYS – the kernel component, stops routing user’s requests to a worker process to dispatch incoming requests from clients. If the application takes 50 seconds more, to be completed, IISRESET command can’t finish stopping IIS during the time. Why? because it doesn’t kill any process, and just sends a message to ask shutting down target services normally & gracefully. If IISRESET command takes long time in your server, you may have this problem(long running applications).
This kind of delay, or waiting is caused by a designed behavior of Windows Services, and it makes sense. However, if this happens in IIS servers, the delay can be included in ‘DOWNTIME’ which can be more serious than shutting down applications gracefully. This matters. IISRESET command tries to shutdown all the components NORMALLY, and then, start them all. So, if it takes a long time to complete any web applications, IISRESET command causes a long downtime of services too.
Once IIS completes all existing requests, it can complete to shutdown all services, and ready to start them. After starting, all the worker processes will be newly started processes. And this means the worker processes are initial state.
More About Side-effects of IISRESET
As it tries to shutdown all IIS components first,
. HTTP.SYS will loose existing client-connections after running IISRESET.
: All incoming requests will need to establish new connections(port 80 by default) again.
. Web browsers can’t connect the IIS server during restarting IIS (downtime).
. While its restarting services, requests from browsers are being missed. (downtime)
. A worker process can’t keep any data – cached objects & binaries
: In-Process session state, compiled binaries for ASP/ASP.NET in a process memory, Application cache.
Recycling Application Pools
Now, recycling application pools is available in IIS6 & IIS7.x. let me tell you how it works.
When you conduct recycling, it invokes a new worker process first, and then shutdown the old worker process. This is the point. You will be able to find that this steps support high-availability of IIS.
For IIS administrators, let’s see the each step of recycling application pools as follows,
In IIS server, run ‘IISAPP’ to identify current application pools(there’s one at the moment),
Check the process ID of W3WP, 884.
(IISAPP is a command, and a script to display PID & name of Application Pool in Windows 2003.)
Now, I run recycling the application pool using IIS Manager.
Just after running ‘Recycle’, you can see that there’re 2 worker processes, by running ‘IISAPP’ command, or in a task manger to display a list of processes.
A worker process with PID-3384, is a newly created process, before shutting down the existing one(884).
After shutting down the old W3WP.exe, we have only one W3WP(3384), a new worker process as shown below.
So, this helps you to understand how recycling goes. It starts a new worker process first, and shutdown previous one. If you remember that roles of HTTP.SYS component, routing incoming requests from client browsers, happens in the kernel. In other words, once recycling happens, HTTP.SYS starts dispatching incoming requests to the newly created process, which belongs a new queue for its worker process, and the old worker process just need to complete existing requests those are already dispatched previously.
By doing so, IIS can handle all the requests while recycling application pools without any requests loss. In addition, http.sys keeps its roles, that means there’s no physical network connection loss between browsers, and IIS server. In this case, there’s no overhead to re-establish network connections those can cause CPU overhead, especially for secure sessions(HTTPs). A worker process can take over WWW services gracefully without downtime.
Does IIS guarantee there’s no loss of current applications during the recycling?
Basically, yes it does, but there’s an exception.
Both IISRESET & Recycling has time-out value. So, applications in the w3wp process can be completed within the time-out, recycling can be done without any abnormal termination of applications.
As shown above, IIS has ‘shutdown time limit’, 90 seconds by default. If the request(or any running application) meets this value, it fails to shutdown without any problem, it means the applications in the process at the moment, can meet an error, because the application pool will be gone anyway. In spite of this time-out error, we can say recycling supports high-availability of IIS services, if you can agree that errors are different issues.
Advantages of using IIS recycling feature
. All the clients can connect IIS server, and every requests will be handled without downtime.
. There’s no connection loss.
. Faster operation than IISRESET to initialize system resource(memory).
Common problems of IISRESET & Recycling
. Any data, stored in a worker process(W3WP.EXE) will be lost.
: In-Proc session state, compiled binaries of ASP/ASP.NET in a process memory, application cache
Which one should I choose for my requirement?
In most cases, you may choose ‘Recycling AppPool’.
let me enumerate common reasons for administrators to run IISRESET, or recycle, as follows,
. Administrators made some changes of IIS settings, and want to apply changes.
. IIS has a memory leak issue. The memory usage of web applications keeps growing.
. Based on findings of your IT staff, it’s recommended to restart IIS in a regular way.
. IIS becomes unresponsive (or much delayed response) sometimes.
Do you have a same reason with the above? For every reasons in above, recycling is enough operation for IIS administrators, rather than running IISRESET which stops all & starts all.
(In terms of memory leak issues in IIS, I’m going to post an article with more technical details. Both recycling & IISRESET can’t fix the root cause of any leak issues. It helps symptom of leak problems. Anyway, a worker process & committed memory for the process will be gone after recycling.)
BTW, any benefits to use IISRESET?
Rebooting Windows servers, or restarting IIS services(IISRESET) can be much more than just enough & effective operations that you need. I hope you already found it.
In a few situations, IISRESET helps. For example, let’s say you have a load-balanced farm(running multiple IIS servers) using a network device(load balancer). The device may detect an IIS server that is restarting IIS services in the server farm, because the device can’t connect the IIS server for a while. As discussed earlier, http.sys – one of IIS core components, manages connections for WWW service(port 80, 443) – is not available during IISRESET. So, the device can have a choice, that letting requests not be routed to the server during its restarting. Someone can prefer this – detecting a web service availability in other tools, or devices. Recycling can’t be detected in any other location without any special & additional helps from the IIS server.
And, when you change a master level settings (open properties window at ‘Web Sites’ node), there’s a ‘service’ tab as shown below.
For making changes in the above, you need to run IISRESET to apply changes.
For the rest settings(any changes in a site level), even recycling is not necessary to apply changes. In terms of application pool settings, and any changes in web.config, or manchine.config files, you had better use Recycling to apply changes quickly & obviously.
You may want to support high-availability & efficient operations.
So, it’s recommended to use recycling when it’s necessary, and run IISRESET for just a few conditions as mentioned in this article.
In IIS6, any changes of most IIS settings don’t require neither IISRESET, nor Recycling. It’s designed to apply changes in the worker process memory(running services) first, and then save it to the metabase file which includes IIS settings, when you make changes in the IIS manager.
In IIS7.x, it’s a bit different to apply changes, but it also doesn’t require IISRESET for most changes.
To make sure this, you will need to test – making changes & verifying them without IISRESET, or rebooting servers. It’s a good idea. I hope the information of this post, can help you to consider ‘Recycling’, when you meet any situations to restart IIS services, and to feel comfortable to do something, because you have a way to minimize impacts on your critical services.