CPU Monitoring and Throttling in IIS 6

You can enable some basic CPU monitoring in IIS, but the downside is you have very few options if a given site takes up too much CPU. You can either a) record something in the event log, or b) have the site shut down. Step a) doesn't prevent the haywire site from continuing to hog the CPU, yet step b) is too drastic.

What we'd really like is a way to throttle a site based on CPU, similar to IIS bandwidth throttling. Thankfully, there's a general way to accomplish this:

  1. Enable CPU monitoring for each app pool (go with 85% or less) and indicate that you want an event log message ("No action"), not a shutdown.
  2. Enable bandwidth throttling for your sites and choose a high default value.
  3. Write a script and schedule it to run every 5 minutes. This script should:
    • Scan the event log and look for messages indicating an app pool has surpassed its CPU limit. It should only consider messages that were recorded since the script was last run.
    • determine which sites correspond to that app pool.
    • lower the bandwidth throttle of each of those sites to some value, maybe 75% of its current throttle setting or 90% of its currently used bandwidth.
    • send an email notification.
    • repeat the above for any other offending app pools.
    • Record the time it started running so that next time it only looks for newer event log messages.
  4. Write a second script that resets the bandwidth throttle values of all sites to their original high values. Run this script once a day during low traffic, e.g. 3am.

Now, any time a site starts taking up too much CPU, your script should automatically throttle its bandwidth down. If that site continues to consume CPU, the script will throttle its bandwidth down further. You could get fancy and keep track of which sites are behaving very badly (i.e. take up too much CPU regardless of bandwidth throttling) and perform some other action (send an email, restart that web site, etc.).

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值