4

What are the effects of IIS's app pool setting for recycling to recycle after "Fixed number of requests"?

Suppose this number is 100, and the 99th person connects to my web site, then the 100th person comes and will trigger an application pool recycle.

Does this mean all session information for sessions 1-99 will be lost (in-process session will expire when application pool worker process restarts)?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
George2
  • 44,761
  • 110
  • 317
  • 455

2 Answers2

5

You basically have it right, but it's not the person, it's the request. Each aspx page called on your application will add up and when the threshold is reached, the application pool is recycled, the application domain (if your using .Net) is unloaded and everything starts up again. You lose Session, Application and any static variables laying around. If your using classic asp or php, every session and global variables are lost too.

A number of hits threshold is a bit overkill. You should either disable it or set it to a huge number. By default, if I recall well, the IIS6 application pool recycles every 15 minutes if there were no request and you can also put threshold on the total memory used by your application to trigger recycling.

Yann Schwartz
  • 5,954
  • 24
  • 27
  • A further question, we could also set IIS worker process recycle at specific time, does it mean (1) at specific time IIS will recycle or it means (2) at specific time if no user is accessing IIS (no active connections), worker process will recycle? – George2 Jun 06 '09 at 09:00
3

That is quite correct. If you do not use some kind of Session farm, or database backing of the session information, it will be lost when the application pool is recycled. I would recommend trying hard to not require any session information - this will make your application more scalable and reliable as it maps more closely to the stateless nature of the underlying HTTP.

1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
  • 1
    A further question, we could also set IIS worker process recycle at specific time, does it mean (1) at specific time IIS will recycle or it means (2) at specific time if no user is accessing IIS (no active connections), worker process will recycle? – George2 Jun 06 '09 at 09:01
  • 1
    IIS will recycle at that time - the application pool will flush all outstanding requests, accepting no new ones, and the stop. A new instance will be started at the same time to handle new requests – 1800 INFORMATION Jun 06 '09 at 09:02
  • Means the same effect -- existing in-process session will be destroyed? – George2 Jun 06 '09 at 09:04
  • 1
    Exactly. Session state is kind of an evil thing since it requires to map across server restarts and server farms and all that other stuff – 1800 INFORMATION Jun 06 '09 at 09:14
  • @1800 INFORMATION, 1. I think recycle at fixed time or at specific number of requests are very dangerous settings, why people need that? 2. If we disable recycle at specific time and also disable at recycle at specific number of requests handled, are there are side-effects? – George2 Jun 07 '09 at 14:14
  • Normally people set those to mitigate the effects of issues such as unbounded memory usage, hangs or crashes due to bugs - if the issue cannot be resolved, or the root cause has not been determined, then setting this can increase reliability in a live environment by recycling the application pool before the bad effects would become apparent. If you have no issues such as this, then you don't need to set the recycling – 1800 INFORMATION Jun 07 '09 at 21:39