Monday, February 22, 2010

Monitoring a web server

I was recently wanted to find how much cpu, disk I/O, memory, and bandwidth was being used by my web server.

After a little research, I found that there are some basic performance counters in the Windows Performance Monitor (Start Menu | Administrative Tool | Performance). It is also known as System Monitor.


To minimize overhead you probably don’t want to run the performance monitor using the current activity graph or anything like that where the UI is needed. To reduce overhead, you really want to use the following instructions to monitor your system.

  1. Open the System Monitor by going to Start Menu | Administrative Tool | Performance.
  2. Expand the Performance Logs and Alerts node on the left navigation.
  3. Right-click the Counter Logs and select the New Log Settings… menu item.
  4. Name your Log as desired
  5. On the General Tab, click the Add Counters… button. Add the counters discussed below under each of the headings.
  6. On the General Tab, you may want to change the interval to 3 seconds, but nothing more frequent than that if you can help it. Otherwise, the overhead will be too much in many cases.
  7. On the Log Files tab, change the Log file type drop down list to be Text File (Tab delimited) or other format of choice if you will be working with the data later.
  8. On the Log Files tab, click the Configure… button to change the location for the log file to be something other than c:\ in case you run out of disk space, you don’t want to crash Windows. You also may want to set a file size limit.
  9. ON the Schedule tab, you can set it to whatever makes sense for you. I prefer manual settings to start and stop the logging.
  10. Your Log settings will now show up in the detail panel to the right.
  11. Right-click your log settings in the details panel, and choose Start to start the logging.
  12. When you are ready to stop the logging, right-click your log settings in the details panel, and choose Stop to stop the logging.


When monitoring CPU activity consider monitoring the following counters:

  • Use: Processor: % Processor Time (default is for one total processors)
    • This tells us the percentage of time the CPU spends executing a thread that is not idle.
    • If you have multiple processors, use a separate instance of this counter for it.
    • Consistent 80% – 90% is considered high and should be reduced.
  • Optional Use: Processor: % Privileged Time
    • This tells us the percentage of time the cpu spends executing MS Windows kernel commands. This could be time processing I/O requests.
  • Optional Use: Processor: % User Time
    • This tells us the percentage of time the CPU spends executing user processes such as SQL Server, IIS, apps, etc.

For more information, see this MSDN page.

Disk Usage

When monitoring Disk usage disk activity typically falls into two areas:

  • Monitoring Disk I/O
    • Use: PhysicalDisk: % Disk Time
      • This tells us the percentage of time that the disk is busy with read/write activity.
      • Above 90% is considered high and should be reduced.
  • Detecting Excessive Paging
    • Use: PhysicalDisk: Avg. Disk Queue Length (default)

For more info (including how to troubleshoot bottlenecks, isolating SQL Server disk I/O, etc), see this MSDN page.

Memory (RAM)

  • Rate at which pages are read from or written to disk to resolve hard page faults.
    • Use: Pages/sec (default)
    • Should be under 1000 at all times.
  • There are so many other stats that you can look at 32 in all. They are all under memory.
    • Click here to get a better understanding of memory and what you need to monitor to answer the questions you may be trying to answer.

IIS Bandwidth

NOTE: These number may be a little lighter than that seen from a Firewall since Multicast traffic doesn’t show up and packets filtered by the firewall also don’t show up*.

  • Rate at which the WWW service is sending  and receiving data in bytes per second (both send and receive total)
    • Use: Web Service | Bytes Total/Sec
    • For more info, see here.
  • The total number of bytes of data that have been sent and received by the WWW service since the service started.
    • Use: Web Service | Total Bytes Transferred
    • To get an idea of how much data for the time you are logging you are actually transferring you will need to adjust all your values to baseline at the first value in your log. In other words, you will need to subtract your first amount from your last amount (assuming the service has not been reset).
    • For more info, see here.

No comments: