IISRESET vs App Pool Recycling ?

 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

.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

Recycling App Pool’ 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

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


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.

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.

IIS Admin Services

Managing the above IIS components using IIS configurations as a Windows Service Management(SVCHost.exe)


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

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 APP Pool

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.

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

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 App Pool’.

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



Comments

Popular posts from this blog

Email Sending through O365 using OAuth Protocol

Deploy .Net6.0 Web api with docker