Home > IIS Stories > IISRESET vs Recycling Application Pools

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.

image

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).

image

 

1. HTTP.SYS

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),

image

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.

image

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).

image

After shutting down the old W3WP.exe, we have only one W3WP(3384), a new worker process as shown below.

image

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.

image

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.

image

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.

image

image

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.

Advertisements
Categories: IIS Stories
  1. pk@gmail.com
    2012/12/14 at 2:09 pm

    Nice and simple explanations. Thanks.

    Like

  2. Mike
    2013/02/14 at 8:22 am

    Great article. I had been using iisreset constantly, battling a memory leak in one of our applications. This will at least buy me some time to figure out the root and keep the app from crashing. Great work!

    Like

  3. 2013/03/11 at 9:21 pm

    Great.. Thanks !!

    Like

  4. Tarkan Koemuercue
    2013/03/23 at 8:30 pm

    Thanks…explained very good

    Like

  5. ganesh
    2013/04/02 at 7:42 pm

    Sir,
    It was an excellent article ,thanks for posting

    Like

  6. shashi
    2013/04/30 at 12:40 am

    nice one!! Much appreciated

    Like

  7. Abdullah Shahin
    2013/05/14 at 9:00 pm

    very beneficial, Thanks!

    Like

  8. Carlos Mtz
    2013/06/22 at 2:07 am

    Very good explanation, clear and good.
    Muchas gracias!

    Thank you.

    Like

  9. Pra
    2013/06/27 at 3:18 pm

    Very Inforamative. Thank You

    Like

  10. 2013/07/02 at 8:41 am

    I do believe all the concepts you’ve introduced in your post. They’re very convincing and will
    certainly work. Nonetheless, the posts are too quick for starters.
    May you please prolong them a bit from subsequent time? Thank you for the post.

    Like

  11. 2013/08/02 at 11:43 am

    Aw, this was an exceptionally good post. Taking the time and actual
    effort to make a good article… but what can I say… I put things off a lot and don’t seem to get anything done.

    Like

  12. satya
    2013/08/11 at 10:40 pm

    nice article

    Like

  13. chain
    2013/10/21 at 5:49 pm

    hi , i left an email to you regarding iis issue. Don’t know if you have receive it , if not can you give me your email address? i have something clueless for quite some time .thanks.

    Like

  14. 2013/10/22 at 1:02 am

    Nice and appropriately detailed content. Very helpful in understanding iis. I might need your help in resolving my issue hosting sharepoint. Two WFEs in load balanced mode. One of them becomes unresponsive very often. I have been running iisreset as sceduled task instead of app pool recycle. I will try and let you know

    Like

  15. Maz Mohammadi
    2013/11/03 at 12:59 am

    Excellent article! Very helpful. Kudos on the job well done.

    Like

  16. Richard
    2014/01/21 at 6:29 am

    Great article Joon, thanks for your clear explanation and pictorial representations. I’ll be banning iisresets for most of our situations.

    Like

  17. Vivek
    2014/02/14 at 2:46 pm

    Quite informative, God bless you for sharing

    Like

  18. manish
    2014/02/20 at 7:49 pm

    Its awesome, completely woth reading..Thanks a lot

    Like

  19. 2014/03/06 at 12:24 pm

    Great beat ! I would like to apprentice while you amend your site,
    how can i subscribe for a blog website? The account aided me a acceptable deal.
    I had been a little bit acquainted of this your broadcast offered bright clear idea

    Like

  20. 2014/03/18 at 12:06 am

    you’re in point of fact a good webmaster. The web site loading pace
    is amazing. It sort of feels that you’re doing any distinctive trick.

    Furthermore, The contents are masterwork. you’ve performed
    a excellent task in this topic!

    Like

  21. Matt
    2014/03/22 at 12:29 am

    Nice work!, you didn’t go into scheduling recycles and best practices for this although you do hint at it a few times basically saying once a day or as needed. There are options for recycle at memory limits and such which I was curious as to proper considerations for this. Now I was asked by my manager to schedule a recycle mid day ontop of the one at night for a issue that randomly occurs. It sounds like this is not the right thing to do. The issue is CPU spikes to 100%, memory is fine, doesn’t look like anything in particular happening although I think I know the cause, not a solution. A recycle fixes the issue and we hum along for a month or two and it might happen again.

    Like

    • 2014/03/24 at 3:05 pm

      As we know, problems in works & life, after school-days, are not likely to have a perfectly right answer. In your case, recycling based on memory size has disadvantages, because of two reasons, the first one is that the issue is not related with the size of process memory, another one is the recycling option, based on any memory size, can be less manageable way, because you can’t expect when it will happen. It’s even worse if you don’t know when it should happen.

      I prefer to fixing the root cause of a high CPU problem in applications level, but if it’s not a feasible way, a simple C# code, or even perfmon can give you a way to automate operations to trigger CPU spikes, and run a prepared script to recycle AppPools.

      Like

  22. Mark
    2014/03/25 at 1:02 am

    This is some good stuff!
    From time to time, I receive warning errors on the system and application logs indicating the ISAPI dll file was in a unhealthy state which triggered an app pool recycle.These errors occur during after hours and only occur an hour after the daily app pool recycle (2:00AM) There is a brief outage on one of my SharePoint applications. Any ideas to why the ISAPI dll file is unhealthy?

    Like

  23. Rupali
    2014/05/30 at 6:55 pm

    Very nice article !! very helpful
    Thanks

    Like

  24. 2014/06/12 at 5:15 am

    Great Post! Thank you for your detailed summary!

    Like

  25. Shweta
    2014/07/25 at 7:52 pm

    Very nice and detailed article. Could you please also share the link for an article “memory leak issues in IIS”, with more technical details. and how can we do this or If we are performing App Pool Recyle then how we can make sure that memory has been increased. or porblem has been solved:).. thanks in advance.

    Like

  26. 2014/08/18 at 5:35 am

    Thank you for sharing your thoughts. I truly appreciate your
    efforts and I will be waiting for your further write ups thanks
    once again.

    Like

  27. 2014/08/22 at 6:16 pm

    Thanks for sharing Joon. As an Outlook Web App administrator, I end up doing an IISRESET about once a week. It’s nice to know that there’s a less drastic alternative. I’ll definitely be trying this soon.

    Like

  28. Simon
    2014/09/09 at 5:23 pm

    Great article but I have discovered on our load balanced system that a previous developer had updated DocIcon.xml on one server but not the other. Having read various articles, most point to IISRESET and a handful suggested RECYCLING. Which one is it?

    Like

    • Simon
      2014/09/16 at 8:04 pm

      UPDATE: I matched the Docicon.xml file on both servers (and also set PDFs to open them in the browser without being asked if I want to edit them). Then I left it for the daily scheduled recycle. Lo and behold, the PDFs are now opening in the browser. No IISRESET required (as 99% of the guides I had found suggested)

      Like

  29. Prabakaran
    2014/09/11 at 9:37 pm

    doest it applicable for AppDomain restart ? I mean when i modify web.config then, AppDomain will be restarted ? would it also be graceful i.e no down time ?

    Like

  30. michaelmaas@costco.com
    2014/10/16 at 1:30 am

    Great article, although I have a related question. Is stopping and starting the IIS server the same as an IISRESET with regards to recognizing changes in the web.config file. My experience indicates they are not the same but I don’t understand why they would not accomplish the same thing. Can you shed some light on this?

    Like

  31. dayi
    2015/02/26 at 6:01 am

    Excelent! Excatly what I was looking for…

    Like

  32. 2015/04/05 at 9:50 pm

    Must have experience and also work weekends.

    Like

  33. Sam
    2015/09/25 at 2:38 am

    I have hosted one application on one of my server, some time it goes down without any error, high resource utilization, or any other issue …. but starts working after IISRESET, Same thing I tried just by doing application pool recycle but it doesn’t worked.

    Any idea what could be the issue? Can anyone please help me on this? I didn’t see anything in any of the logs even I could see IIS and application pool is showing up and running but still application goes down and comes up as soon as it gets IISRESET commands.

    Like

  34. 2016/08/12 at 9:16 pm

    very useful article for beginner.

    Like

  35. 2016/11/04 at 11:16 pm

    If you need to delegate access to non-admins to start, stop or recycle application pools *and* have a full audit trail about it – take a look at System Frontier.

    Like

  36. Angela
    2016/12/09 at 1:32 am

    Excellent explanation, thank you!

    Like

  37. 2017/02/07 at 3:39 pm

    Thanks for the explanation!

    Like

  38. 2017/05/12 at 11:01 am

    Hi, sometimes I see a 404 website error when I arrive at this webpage. I thought you may wish to know, cheers

    Like

  1. 2013/02/28 at 11:16 am
  2. 2013/12/04 at 9:16 am
  3. 2014/08/11 at 3:51 am
  4. 2014/09/11 at 4:38 am
  5. 2015/04/07 at 6:48 am
  6. 2016/09/19 at 3:38 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: