How to correctly reset, restart, and recycle IIS websites

IISRESET website downtime vs application pool recycle
If you manage iraqi intelligence service websites, you ’ ve probably asked these questions many times :

  1. Should I use IISRESET to restart IIS services?
  2. Should I recycle my IIS application pools when the website is slow, failing,
    queueing, or is consuming too much CPU/memory?
  3. How can I reduce application pool recycling, or application restarts, to
    improve my website availability?

If sol, this guide is for you. Read on to learn what happens when you restart IIS services, when you should recycle your application pools, and how to do it in the safe and most effective way possible .
I ’ ll besides show you how to restart IIS applications with ZERO downtime. And how to set up high handiness, recycle kind, always warm websites that experience ZERO inauguration delays even when they recycle .

How to reset IIS the right way

Your IIS web site is designed for always-on custom. still, there seem to be many reasons why you may need to restart parts of your IIS web push-down list.

During the last 10 years at LeanSentry, we ’ ve seen more than a bonny contribution of customers restarting their web servers. Including using IISRESET, or recycling their lotion pools to try to solve performance and dependability problems. In many of these cases, restarting did not ultimately help, and in some of them, actively hurt the web site ’ south handiness .
here are the top reasons we ’ ve seen :
In this usher, we ’ ll labor into each case and find how to reset IIS the best way. The answer much is NOT to restart it. If a restart is actually desired, we ’ ll look at the fresh ways to do it without negatively impacting your web site ‘s handiness .
Before we do, let ’ s get one thing out of the way .

IISRESET: the IIS restart
command to avoid

Resetting IIS with the IISRESET command causes the most website downtime.
Whatever your goal, resetting IIS or stopping IIS services is not the mighty answer .
I wish we had removed the IISRESET command when we shipped IIS 7.0 in Windows Server 2008. unfortunately, besides many people were already relying on iisreset as their independent two resume method. The team did not want to create a break change for people ’ randomness scripts, so they kept it around .

History of the IISRESET command

IISRESET is a dinosaur from the before-times, specifically before IIS 6.0 shipped in Windows Server 2003. With IIS 5.0 and earlier versions of IIS, the web server was a monolith. An IIS reset cock was needed for restarting the web server process to resolve performance issues that may have developed in the application .
IIS 6.0 introduced the application pool architecture. This separated the web site application code ( hosted by the IIS actor march, w3wp.exe ) from the IIS system framework ( Http.sys kernel driver, and W3SVC listener service ) creditworthy for receiving requests .
consequently, iisreset.exe was nobelium retentive needed to restart the application. placid, it remained in the intersection as the “ easy ” but entirely excessive means to reset IIS .
IISRESET is a out of practice hammer that inflicts a batch of price on your server, but has little preciseness. The huge majority of the scenarios for restarting IIS are centered on restarting a misbehave application or proletarian action. Because of this, recycling the lotion pool wins every time .
Which means resetting IIS this means is always wholly unnecessary .
Worse, using the IIS reset command causes significant impingement to your web site ’ s handiness .
This includes :

  1. Shutting down all application pools, and terminating all
    incoming requests. This will make ALL your websites unavailable for the entire
    duration of the shutdown. Compare this with IIS application pool recycle, which
    affects only a single apppool and maintains 100% availability.
  2. Stopping other system services (which may make your server
    unstable or unavailable).
  3. Potentially failing to bring those services back, leaving
    your server inoperable.

For a detail explanation of the problems caused by IISRESET, and the relative benefits of using targeted application pond recycle, please see Dangers of using IISRESET to restart IIS services .

Stopping IIS services

Before we dig into each scenario, it ’ second crucial to understand the key parts of the IIS web site push-down list. We ’ ll besides look at when and why you may need to restart them, and when you truly don ’ t .
If you already know all of this, feel spare to skip ahead .

IIS services you can reset

The diagram showing all the key IIS services and components of request processing, that can be restarted. Includes WAS, W3SVC, Http.sys, application pools, and the ASP.NET application
These services comprise the system infrastructure of IIS, helping it receive and dispatch incoming requests to the IIS proletarian march. The proletarian action then actually hosts your application code and request process .

  1. Http.sys. Kernel listener that receives the requests by
    listening on website binding endpoints. It then allows IIS worker processes to
    dequeue these requests for processing.
  2. W3SVC. The IIS web service that configures Http.sys to
    listen for requests based on your IIS website configuration.
  3. WAS/WPAS. The IIS service that coordinates the creation of
    worker processes based on your application pool configuration.
  4. Application pool. This is a logical container, not a
    physical process. The application pool routes request processing for a set of
    applications in your website to a specific IIS worker process.
  5. IIS worker process (w3wp.exe). This is the actual runtime
    host for the application, where request processing takes place. When we talk
    about restarting or recycling the application pool, we are actually talking
    about starting a new fresh worker process.
  6. Application. An IIS application maps a url in your website
    to a physical ASP.NET application domain that’s hosting your application code.
    When you are having performance issues, it’s the application code and its memory
    state that is usually causing the trouble. It could be a hang, high CPU, or a
    memory leak … the application is the piece we really need to restart.

Let ’ s get this extinct of the way .
The core IIS services ( Http.sys, W3SVC, WAS ) never need to be restarted. rather, they mechanically detect any relevant configuration changes ( e.g. raw web site being created, or a change in your lotion pool settings ) and apply them on the fly .
You should not, but COULD restart these services as follows :

Service How to restart it What happens when you restart it
Http (Http.sys) net stop http && net start w3vc All current requests aborted, downtime during W3SVC
All application pools recycle when w3svc
Risk of kernel driver getting stuck in a stopping state,
requiring server reboot.
W3SVC net stop w3vc && net start w3svc All current requests aborted, downtime during W3SVC
All application pools recycle when w3svc re-starts.
WAS/WPAS net stop was && net start w3svc All current requests aborted.
All application
pools shut down, downtime until WPAS restarts.

The IISRESET control is roughly equivalent to restarting the WAS servicing. This triggers the stop of the W3SVC service, and the closure of ALL IIS application pools. All of that can take a very retentive time on a production server, causing extended downtime .

Downtime test of IISRESET, WAS restart, application pool stop and recycle

We performed a product downtime quiz to illustrate the relative impingement of all the different ways you can restart or recycle your IIS services .
In this test, we applied a mix warhead to a simple world wide web lotion, which included 50 requests-per-second to a fast page and 2 active requests to a slower page that took ~10 seconds to execute. We then attempted to reset IIS or shutdown/recycle the test application pool, measuring downtime, and any errors experienced by our test node .
At the lapp clock time, the server continued to serve two other production websites supporting LeanSentry services .
Downtime impact of IISRESET, WAS restart, apppool stop and recycle
As you can see in the results, IISRESET and WAS restart caused the most downtime, ascribable to stopping the application consortium and being forced to wait for all application pools to shut down. In contrast, recycling the test application pool caused zero downtime !

IIS application pools, and worker processes (w3wp.exe)

The IIS worker processes in each apppool are the ones hosting your application code and serve requests. They are besides the ones consuming waiter resources ( e.g. CPU or memory ) .
IIS mechanically applies changes to the application pool configuration by doing an “ overlapped recycle ”. This swaps the current application pool ’ mho worker process with a new fresh one .
You can manually trigger an overlap apppool recycle from IIS Manager, or with AppCmd as follows :

Appcmd recycle apppool POOLNAME

MASSIVE advantage of recycling a specific application pool

Separating websites and applications into different application pools enables you to restart the claim function of your web site that needs it .
This has the be key advantages :

  1. No server-level impact for other sites and pools.
  2. No extended downtime due to waiting for ALL other application pools to stop.
    This is huge on a server with multiple apppools.
  3. No downtime due to waiting for the target application pool to stop.
  4. (If you have it configured) full warmup/zero startup time for the new worker

Bottom tune, the targeted overlapped recycle method offers ZERO downtime for the target application pool. We ’ ll explore this in detail next .
Compared to this, iisreset or resume be causes the closure of ALL application pools. This includes waiting for requests in all lotion pools to finish, up to the closure clock time limit. This could mean up to a minute and 30 seconds of downtime from each application pool .
not to mention, that all other application pools will need to come up again after the restart. They will then experience the low-level formatting viewgraph and inauguration stay. This can place an intense load on the server, resulting in extra downtime .

Overlapped recycle to the rescue

IIS application pool recycle is the best method for restarting IIS applications in production, with 0 website downtime.
When the lotion pool recycles, it uses a process called “ overlapped recycle ” or what I call “ graceful recycle ”. This process allows IIS to start up a new proletarian process, with zero downtime and zero requests failing across the transition .

The process works roughly like this :

  1. Start a new IIS worker process.
  2. Wait for the process and the application to initialize (requires IIS 8.0 and
    application initialization)
  3. Start sending NEW requests to the new worker process.
  4. Tell the current worker process process to shut down, finishing out any
    existing requests (until a timeout).

As a leave, whenever the application pool is gracefully recycled, no requests are lost .
Let me repeat this key indicate .
During the overlapped recycle, NO REQUESTS ARE LOST. This means that you can handle most cases requiring a recycle without any affect to your web site ’ mho handiness .

Overlapped recycle vs. IISRESET

Comparing the overlap recycle to IISRESET is like comparing apples to … apples that have been bashed into obliviousness by a hoary forge. The key difference is that the overlap recycle makes sure all requests are handled by either the raw or the previous proletarian process, resulting in zero downtime .
By comparison, IISRESET, restart WAS, deoxyadenosine monophosphate well as starting/stopping the application pool, all stop the lotion consortium. During the arrest, all new requests are rejected while we wait for existing requests to finish ( up to the closure time limit, 90 secant by default ) .
IISRESET and WAS resume besides shut down EVERY application pool, so the downtime can be angstrom long as the longest application pool stop … AND affects every single application pond on the arrangement .

even with the overlap recycle, there are some potential impacts to consider. This includes cold starts, long inauguration delays, and state loss issues. We ’ ll look at that adjacent .
That said, as you ’ ll examine below, you should aim to use the overlap recycle in about all cases. It decidedly gives you the lowest impact of any early approach. To take it up a notch, use our Maximize IIS Application pond handiness guidebook to enable recycling with entire warmup and no inauguration delay .

Recycle the right application

To get the advantage of zero-downtime benefits, you need to recycle the right application pool. sometimes, this requires you to find the pool to recycle .
Say you have a w3wp.exe that is experiencing an issue. You can promptly find and recycle it ’ mho lotion pool like this :

appcmd list wp / /xml | appcmd recycle apppool /in

Or, say your web site is hanging and you want to recycle the represent pools. This command will recycle the application pools where requests are taking more than 10 seconds :

appcmd list requests /elapsed:10000 /xml | appcmd recycle apppool /in

You can run the same commands to show you the lotion pool names rather of recycling right away, e.g. :

appcmd list wp / /

Use this appcmd command to identify and recycle the IIS application pool to which the target IIS worker process belongs

The hidden
costs of recycling IIS application pools

Despite the no-downtime promise of the elegant application consortium recycle, recycling hush carries costs. These costs can be severe for some applications .
It ’ s crucial to be mindful of these costs when planning your recycle scheme .

Loss of state

Some applications maintain in-memory express, which can be lost during a recycle. This can cause an interrupt exploiter experience ( such as a lost denounce handcart, an abort data entry session, or a logout ). This is most common with ASP.NET applications that use InProc session state .
When the lotion pond recycles, and the new worker process/application comes up, it nobelium longer has the exploiter department of state .
Applications that maintain in-memory express are not recycle tolerant .
unfortunately, this besides means they are not broad of application restarts, actor process crashes, and waiter restarts .
last, in-process state applications can not well scale. Some applications implement per-user or per-session burden balancer affinity … which creates unmarried points of failure and uneven scale. ultimately, in-memory state is a poor application computer architecture and should be avoided .
rather, we recommend migrating to durable “ out of process ” state e.g. such as SQL or ASP.NET submit serve based session submit .

Initialization overhead

When the application consortium recycles, a newfangled application comes on-line. many applications require an low-level formatting work to build up the data and caches they use for operation. This process can take some time, and introduce processing overhead .
This is one reason why recycling under traffic-induced high CPU is not a estimable idea. Read more on this in the IIS worker process has high CPU scenario below.

Startup delay

alike to the low-level formatting overhead, the inauguration check is the time it takes for the application to in full initialize. During the overlap recycle, the old actor summons stops processing raw requests angstrom soon as the new action starts. This happens evening though the new actor summons has not completed application startup .
As a consequence, the new application may take a long time to complete its low-level formatting procedure. During this time, the application efficaciously appears hang and incoming requests wait for the app init lock .

Requests blocked in application initialization

If this is happening, you ‘ll see a batch of requests queueing up in the IIS Web Core, BeginRequest stage. These requests are waiting for a individual request to complete the application startup code, typically in the Global.asax Application_Start consequence .
Requests waiting for application initialization stuck in BeginRequest inside IIS Web Core
This is a serious trouble for bigger production applications, which can require a lot of cached data. That in turn causes a pretty considerable inauguration delay .
The good newsworthiness is that you can achieve a zero downtime, zero inauguration delay exemplary with IIS 8.0+. To do this, you ’ ll necessitate to use a proper application low-level formatting strategy. This works by setting your application to complete its startup BEFORE IIS switches incoming requests to the new worker process. Until then, the existing worker process will continue serving those requests .
To see how to implement this step by tone, please see our Maximum IIS application pool handiness with Application Initialization guide .

Loss of cache/cold start

The final trouble to be aware of is coldness start. This results from application caches being empty after inauguration. empty caches can cause your application to experience slower performance until the caches build up again .
If your application experiences poor performance after a cold start, it ’ randomness time to consider preloading the cache on application start. This is what happens with most applications that have a startup delay … they are preloading the caches !
If you want to have the best of both worlds : warm caches on startup, and gloomy inauguration delays, consider two strategies :

  1. Application warmup (see previous section). This makes sure
    your application is warm before it goes into service.
  2. Background cache preload. This is a hybrid approach where
    the application preloads the cache after starting, but in the background. This
    way, new requests are not blocked. We use this approach at LeanSentry quite a

thankfully, this problem excessively is solvable. You can configure application low-level formatting to warm up your app with zero inauguration stay. For the measure by step process, see maximal IIS application pool handiness with Application Initialization .

When to restart or

Let ’ s dig into each resume scenario to explore the pros/cons of recycling, and the best way to handle it .
here we go .

sure that IIS has picked up website, application pool, or configuration

IIS 7.0+ is designed to mechanically pick up shape changes. This happens whenever you deploy a modern web site, change web site bindings, or modify any other server-level shape. IIS mechanically applies your changes to :

Change How it’s applied
IIS website and application pool changes (applicationHost.config) WAS and W3SVC automatically detect changes to website and application
pool definitions, and reflect them into the Http.sys listener configuration on
the fly.
IIS feature configuration (applicationHost.config) IIS modules that implement the features automatically detect feature
.NET framework configuration (framework.config, root web.config) Any changes to these global files cause ALL ASP.NET applications loaded
by any worker process to restart.
Web.config (application level) IIS triggers a restart of the affected application.
Web.config (url level) Changes are detected/reflected automatically by the configuration system
for each subsequent request.
Application file changes Changes to key application files (web.config, BIN, App_Code, etc) are
detected automatically and cause application restart.
Changes to compiled content files, e.g. ASP.NET pages, are detected mechanically and trigger active recompilation. This can besides cause application restart after so many recompiles to reduce assemblies loaded in the app .
CLR configuration (for application pool)
E.g. Aspnet.config in carbon : \Windows\Microsoft.NET\ Framework64\v4.0.30319
Custom path set in ClrConfigFile assign for the application pool .
Changes are NOT detected automatically, must recycle
affected application pool to pick up.
registry keys
Changes are NOT detected automatically, must recycle
affected application pool to pick up.
Trusted root certificates (affects trust for SSL certificates
Changes are NOT detected automatically, must restart
W3SVC to take effect.

therefore, as you can see, restarting to pick up configuration changes is normally not necessity .
It ’ second besides undesired, because you are probably going to cause your application pool to recycle multiple times. This triggers extra, unnecessary low-level formatting command processing overhead time. Worse, you may end up recycling more than necessary, e.g. restarting all the applications in the application pond rather of barely the involve application .

Deploying multiple changes without multiple restarts

If you are making many capacity and config changes, you run the risk of causing multiple application or application consortium restarts. There are a few tricks to manage this, including dropping the App_Offline.htm file into the lotion directory during your publish process .
You can besides set the WaitChangeNotification and MaxWaitChangeNotification properties to delay application restarts ( this does not work for web.config unfortunately because IIS detects that switch and restarts the app right away ) :
Setting WaitChangeNotification and MaxWaitChangeNotification in the httpRuntime element
In the worst font, you can always stop the application pool and restart it after deployment is made. In fact, deploying thousands of websites may be the only legalize use case I can find for stopping WAS during the deployment .

Website is not responding, or is

This is the most common “ production ” cause of restarts and recycles. When the web site hangs, most people panic, because they normally lack any data about what is causing the problem .
thus, they often reach for the reset button and hope for the best .
This does sometimes help, although temporarily, and the problems normally return. sometimes right away ! Most importantly, restarting your web site makes surely that you will continue to have performance problems ! Simply because restarting prevents you from being able to determine WHY the site is hanging or slow and eliminating that rout campaign .
here is what to do rather :

  • 10x better: Diagnose the cause of the hang or slowdown, e.g. by using LeanSentry Hang diagnostics
  • Recycle the right application pool (if desperate).

( If you don’t fix the hangs, they are sure to keep returning. )

Why do some hangs return after recycling?

Recycling can temporarily relieve string blockage, but it does not address the underlie trouble. then, there is a high risk that the hang will quickly return .
For case .
If you are having a hang during point traffic, due to threads being blocked ( e.g. by a boring SQL question ), badly times can return quickly. The new worker summons will much quickly hit the same hang condition. This happens because the fresh proletarian process will normally start with fewer threads. The bombastic collapse of incoming requests will make indisputable that the those raw threads will all get blocked in the lapp code and much more quickly than earlier .
We ’ ve helped over 30,000 websites resolve hangs with LeanSentry. From this know, we do sometimes see emergency value in recycling hang application pools. But, since most hangs are caused by behind external resource recovery, or thread pond debilitation, recycling is normally not helpful : ( .
Bottom line, you should constantly prefer to diagnose/resolve hangs to recycling the lotion consortium .
You can learn to troubleshoot IIS and ASP.NET hangs manually in our Hang trouble-shoot usher, but I would advise using LeanSentry hang diagnostics to get it done promptly and faithfully .

How to diagnose IIS website hangs with LeanSentry

You can use LeanSentry Hang diagnostics to mechanically detect and analyze IIS and ASP.NET web site hangs :
LeanSentry detecting an IIS website hang in production
LeanSentry will then identify the application code causing the hang so you can resolve it promptly :
Use LeanSentry hang diagnostics to identify the root cause of website hangs, including the application code causing blocked requests or thread pool exhaustion.

IIS worker process has high CPU usage

Your consortium ’ south worker march is consuming excessively much CPU, resulting in slower responses. possibly it ’ s causing the server CPU to become overladen .
This is another common reason for recycling application pools in production .
Go to the Diagnose w3wp.exe high CPU usage guide for the step-by-step for resolving high CPU usage correctly.
however, recycling these overworked worker processes can have a hard downside. The higher custom is about always due to a confluence of higher load and heavier than desired processing by the application .
When you recycle the pool, the system will end up working even harder. This happens because the new proletarian march will be processing the same warhead, but without the benefit of full caches. And this is on top of any low-level formatting command processing overhead time costs .
In other words, recycle is likely to make a production CPU trouble regretful .
here is what to do rather :

  1. Reduce load on the server, or spin up another server (if in a cloud
  2. Diagnose the code causing the CPU usage.
  3. Optimize this code to make your application more CPU-efficient.

again, using the write out as an opportunity to diagnose the etymon lawsuit constantly wins over temp recycle .

How to diagnose high w3wp.exe CPU usage with LeanSentry

You can use LeanSentry CPU diagnostics to track down the application code causing high CPU usage in production websites. LeanSentry automatically detects and diagnoses high gear CPU incidents, so you can get to the root of the issue quickly .
LeanSentry CPU diagnostics automatically determines application code causing high CPU in the IIS worker process
You can use the CPU diagnostics reports to determine the exact code pathways that are causing elevated CPU usage, so they can be optimized .
CPU usage code flamegraph

IIS worker process has high
memory usage

This one is a bit different. This is because memory leaks normally take put over clock, due to collection of objects that are not properly released ( e.g. cache explosion ) .
As a result, recycling the application pool can be an effective bandaid for applications with memory leaks .
See the Diagnose w3wp.exe high memory usage guide for a step-by-step on fixing IIS memory leaks.
At LeanSentry, we see that approximately 60 % of .NET applications experience elevated or leaky memory use in production. Because production memory optimization has been historically unmanageable, it ’ s normally not done until it becomes a unplayful trouble. The downside of this is that many websites require memory-based recycle to keep the server from running out of memory .
Another downside is cost. Sites with memory issues frequently experience a 2-4x increase in obscure costs ( due to needing to run EACH example with more memory ) .
Of course, we recommend diagnosing and optimizing memory custom regularly to keep your costs low. This will besides help you reduce need for recycling, and increase overall performance by lowering Garbage collection overhead. You can read more about this in our IIS actor action memory optimization template. These are all great benefits for certain and well worth it .

How to diagnose high w3wp memory usage with LeanSentry

Use LeanSentry Memory diagnostics can help you determine the code in your application that is causing gamey IIS memory usage/w3wp memory leaks in production .
LeanSentry Memory diagnostics determines the code and objects causing production memory leaks and high memory usage in your ASP.NET applications
While you work on diagnosing/optimizing your code, you can configure automatic memory-based recycling. This will make IIS recycles your application consortium when it exceeds a sealed memory doorsill .
To automatically recycle the actor march when it reaches a debatable memory doorway :

appcmd set apppool POOLNAME /recycling.periodicRestart.privateMemory:PRIVATEMEMORY-IN-KB

We recommend recycling well before you exceed 80 % of available RAM on the waiter .

Your website is returning
HTTP 503 errors

There are many reasons why IIS may return 503 errors, including “ Service Unavailable ” and “ Queue Full ”. These errors normally have to do with WAS failing to allocate a actor process for the application consortium in doubt. Or, the worker procedure failing to dequeue requests from the application pool queue .
You need to know what kind of trouble you are dealing with to know if a recycle will help. For case :

  1. If WAS is failing to start the IIS worker process due to a persistent error,
    e.g. mis-configuration, recycling will not help.
  2. If the application pool queue is full, recycling the worker process is
    unlikely to help in most cases.

There is one specific casing to be mindful of, and that is Rapid Fail Protection. RFP kicks in when the IIS worker action crashes more than 5 times in 5 minutes. When it does, WAS will disable the application pond to prevent future failures. This immediately means that your applications in the pool are permanently polish .
To recover, you can START the application pool again. however, then you are likely to have more crashes. The right solution here, as always, is to diagnose the crash itself and remove the root causal agent .

Diagnose 503 Service Unavailable outages with LeanSentry

LeanSentry Error diagnostics mechanically diagnose causes of Service Unavailable and Queue full moon incidents in production. Look for critical error alerts that identify the code-level beginning causes of 503s including crashes, CPU overloads, and many others .
LeanSentry automatically determines root cause of IIS 503 - Service Unavailable and Queue full errors.

Your website is not
loading, or returning errors

Does “ not loading ” refer to requests that are hanging ? then see the Website is not responding or is slow section earlier in this guide .
If you are receiving errors, a recycle will help only if the error is ascribable to a bad state. And only if that state is cleared when your application restarts. If the error is due to a persistent write out ( misconfiguration ) or external problem ( SQL server is down ), recycling will not help. In fact, it could make things worse by triggering the extra overhead of application startup .
Because the correctly answer depends on the specific error, the best thing to do is get the wax error details. This will allow you to directly address it rather of hoping it goes away after the resume.

Resolving production errors with LeanSentry

If you are using LeanSentry, you can use it to get production error details for all production errors across the entire IIS stack.

LeanSentry detects errors in Http.sys, IIS, ASP.NET, and the application


In conclusion, you can take the following actionable steps to deal with recycling in your production IIS site :
Most importantly : resolving the issues causing you to recycle is ALWAYS better than restart .
If you are recycling because of hangs, CPU overloads, memory leaks and the like, deploy LeanSentry to diagnose and fix those issues the right way .
IIS hangs, high CPU, memory leaks

source :
Category : Tech

About admin

I am the owner of the website, my purpose is to bring all the most useful information to users.

Check Also


Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.