IIS7: How to handle application pools which uses too much memory or CPU?

5,227

Solution 1

Have you tried setting the Recycling Conditions for your app pool? You can configure IIS to recycle the app pool at fixed intervals, fixed number of requests, at specific time or at certain memory thresholds.

  1. Run inetmgr
  2. In the Connections pane, expand the server name, and then click Application Pools
  3. Select desired application pool
  4. In the Actions pane, click Recycling

This will not recycle based on cpu usage though, but at least you can have the app pool recycled at certain intervals.

That said, I don't think that you should need to recycle the app pool under normal circumstances. If you need to do this very often, I'd say you either have a "bad" application or you need to give the application more resources.

Solution 2

Windows Server Resource Manager is recommended while installing IIS. It's included with some Windows Server editions - check out your Features list to see if it's there.

This utility is application pool aware, and lets you limit CPU and working set for application pools.

This is less destructive than a CPU consumption-based recycle trigger, but needs careful setup. It typically only makes a difference when one app pool is overconsuming, which sounds like your situation; it might be worth checking out.

Share:
5,227
GrZeCh
Author by

GrZeCh

Updated on September 18, 2022

Comments

  • GrZeCh
    GrZeCh almost 2 years

    How to handle application pools which uses too much memory or CPU? I would like to have possibility to select for how much time application pool is using certain amount of memory or cpu (or both) before it will be recycled. Any idea how to achieve this? IIS7 allows to kill app pool when it reaches some level of CPU usage but I'm interested in recycling it.

    Thanks

  • GrZeCh
    GrZeCh about 13 years
    Recycling in Actions is not covering scenario with high CPU usage. In my hosting environment when app uses too much CPU it's quite hard to explain some customer that his app is "bad". Especially when he only is using it (programmed by someone else). Disabling this app of course will cause phone to ringht right away with questions like "WTF my site is not working ..." etc. So I would like to have all wrong app pools using too much CPU over some period of time to be recycled only. I don't want to disable them when they use too much CPU but just recycle.
  • Nils Magne Lunde
    Nils Magne Lunde about 13 years
    I guess you would have to solve this with some kind of whatchdog that is using appcmd for controlling the app pool. This whatchdog can be made using powershell f.ex.. The syntax for recycling an app pool is appcmd recycle apppool /apppool.name: [App pool name]. To list running processes in IIS, you can use the appcmd list wps command. From that command you get the PID for the process. This PID can later be used to obtain CPU usage by using the get-process command in Powershell f.ex..
  • GrZeCh
    GrZeCh about 13 years
    I was thinking about it but I was hoping it can be done easier. Thank you.