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).
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),
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.
Leave a comment Cancel reply
Categories
- C# on .NET (5)
- IIS Stories (10)
- IT in a usual life (3)
- Travelling Korea (5)
About writer
.
Choi, Joon
Microsoft MVP – IIS/ASP.NET, Enterprise mobility (2012 – 2018)
.NET Developer and IIS/ASP.NET Trainer
————————————————
Ontario, Canada
fullsocrates@hotmail.com
Top Posts & Pages
Recent Posts
- Azure Information Protection – How to implement AIP, (#2/3)
- Azure Information Protection – What AIP is, (#1/3)
- How to restrict a user access for PC at home – to prevent children from playing games all day
- How to publish SSRS report to anonymous web site using ASP.NET (#3/3) – Buiding ASP.NET application
- How to publish SSRS report to anonymous web site using ASP.NET (#2/3) – Buiding SSRS reports
- How to publish SSRS report to anonymous web site using ASP.NET (#1/3) – Prerequisites
- SQL CLR to use C# class for SQL functions, and stored procedures
- How to transfer DataTable Object, using HTTP POST parameter
- .NET Debugging #3/3 – Finding ASP.NET pages of High CPU Problems
- .NET Debugging #2/3 – Checking ASPx Pages running in IIS Process
Nice and simple explanations. Thanks.
LikeLike
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!
LikeLike
Great.. Thanks !!
LikeLike
Thanks…explained very good
LikeLike
Sir,
It was an excellent article ,thanks for posting
LikeLike
nice one!! Much appreciated
LikeLike
very beneficial, Thanks!
LikeLike
Very good explanation, clear and good.
Muchas gracias!
Thank you.
LikeLike
Very Inforamative. Thank You
LikeLike
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.
LikeLike
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.
LikeLike
nice article
LikeLike
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.
LikeLike
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
LikeLike
Excellent article! Very helpful. Kudos on the job well done.
LikeLike
Great article Joon, thanks for your clear explanation and pictorial representations. I’ll be banning iisresets for most of our situations.
LikeLike
Quite informative, God bless you for sharing
LikeLiked by 1 person
Its awesome, completely woth reading..Thanks a lot
LikeLike
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
LikeLike
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!
LikeLike
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.
LikeLike
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.
LikeLike
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?
LikeLike
Very nice article !! very helpful
Thanks
LikeLike
Great Post! Thank you for your detailed summary!
LikeLike
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.
LikeLike
Thank you for sharing your thoughts. I truly appreciate your
efforts and I will be waiting for your further write ups thanks
once again.
LikeLike
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.
LikeLike
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?
LikeLike
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)
LikeLike
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 ?
LikeLike
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?
LikeLike
Excelent! Excatly what I was looking for…
LikeLike
Must have experience and also work weekends.
LikeLike
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.
LikeLike
very useful article for beginner.
LikeLike
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.
LikeLike
Excellent explanation, thank you!
LikeLike
Thanks for the explanation!
LikeLike
Hi, sometimes I see a 404 website error when I arrive at this webpage. I thought you may wish to know, cheers
LikeLike
What I in reality think most in regard to is wellbeing ideas.
On my own, I signed up for journals that concerns this subject matter, and I retain enlightened about the latest wellness lab analyses.
How is this important? I feel there’s no more
crucial focus for my time. Likewise, this blog page seems as if it’s worth my time to read.
I sift through thousands and thousands or even more of personal blogs every week.
Truth be told, my backbone nearly always is painful and I desire a
different spare time interest. lol Anyways,
I think if everybody published about their place in the world, and did it
articulately, we’d have a more interesting Internet. http://speroda.org/index.php/component/k2/itemlist/user/12810
LikeLike
WONDERFUL Post.thanks for share..more wait .. 😉 ?
LikeLike
Hello to all, how is the whole thing, I think every one is getting more from this site, and your views are fastidious designed for new viewers.
LikeLike
Hello to every one, the contents present at this web page are genuinely amazing for
people experience, well, keep up the good work fellows.
LikeLike
Thanks for the great article. After numerous searches on google I finally ended up here. None of the other website go in such depth and detail. Thanks for taking time out to put this amazing article out here.
LikeLike
Elle est la championne dans sa catégorie de poids , donc je suis très fier d’elle.
LikeLike
Nice Explanation, Thanks 🙂
LikeLike