Monitoring Your Web Application
page 1 of 1
Published: 09 Oct 2003
Unedited - Community Contributed
After the main coding is done enough to make the website live what can you do to prepare for up and coming problems with mainly scalability.
by Terry Voss
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 10292/ 32

Monitoring your Website

Monitoring your Web App

Author: Terry Voss

Any web site that is expected to grow needs more than a good use case, design, and good coding. Reports may run fast at first, but you had no idea that the number of units reported would be growing so fast. Why would our customers sit for hours clicking their mouse as fast as they can on one submit button? Why are our customers guessing other customer's passwords? Why does the server seem to lock up once in a while? How could that external server that we are relying on for most hits hold us up this much? Are user counts going to keep climbing at this rate? Many thoughts can come to mind as the feature creep begins to relax a bit.


The action of monitoring your application as its use grows to understand where it most needs to be scaled up or out becomes important. What are some of the ways of doing this?


These types of questions can be answered easier if there is a hitlog in place. Using the tickcount property of the environment class one can create a custom class such as:

Public Class Timer

  Private StartTime As Integer

  Public Sub New()



  End Sub

  Public Sub StartTimer()

    StartTime = Environment.TickCount

  End Sub

  ReadOnly Property MilliSecondsElapsed() As Double


      Return (Environment.TickCount - StartTime)

    End Get

  End Property


  ReadOnly Property SecondsElapsed() As Double


      Return MilliSecondsElapsed / 1000

    End Get

  End Property

End Class


You can instantiate Timer  in the constructor of your page objects, and the timer is started. Then in the page_prerender event you can execute a method like:
curAgent.CreateHit(Timer.SecondsElapsed(), Page.ToString.Substring(4).Replace("_", "."))

Passing SecondsElapsed and a PageName parameter pair.


This measures the time to load a page. Then from page constructor again to complete a postback method another createhit is used, and then just before a server.transfer("otherpage.aspx") or response.redirect("otherpage.aspx") put a createhit call.


CreateHit looks like this:

Public Function CreateHit(ByVal seconds As Double, ByVal pageName As String)

  Dim hitTime As String = DateTime.Now.ToString("G")

  Dim ip As String = Current.Request.ServerVariables.Item("REMOTE_HOST")

  Dim user As String = Current.Request.ServerVariables.Item("LOGON_USER").ToUpper

  Dim length As Integer = Current.Request.ServerVariables.Item("CONTENT_LENGTH")

  storedProcedure = "pr_hitlog_Insert"


  sqlData.AddParameter("@dadatetime", ssenumSqlDataTypes.ssSDT_DateTime, 8, hitTime)

  sqlData.AddParameter("@sip", ssenumSqlDataTypes.ssSDT_String, 15, ip)

  sqlData.AddParameter("@susername", ssenumSqlDataTypes.ssSDT_String, 10, user)

  sqlData.AddParameter("@spage", ssenumSqlDataTypes.ssSDT_String, 50, pageName)

  sqlData.AddParameter("@iclength", ssenumSqlDataTypes.ssSDT_Integer, 4, length)

  sqlData.AddParameter("@fseconds", ssenumSqlDataTypes.ssSDT_Decimal, 53, seconds)

  Dim id As Integer = sqlData.RunProc(storedProcedure, True)

End Function


Now you can write some reports or just do some queries and answer some questions. You could also solve some observed problems. For example you can write a Windows Service that looks at the hitlog for any IP creating more hits than would be possible if that IP was doing real work. You can lock that ip out until you two can get together and discuss the issue. The only problem with this method is that you are doing a lot of programming and therefore you have less time to observe and think about directions that you should be heading in.


The more activity a web farm of web gardens gets, the more testing before introduction of new features becomes important. The testing takes time. You need to automate it. NUnit is a .NET testing system that works with VB & C# .NET and other languages also. It is easy to setup and work with. I like how you can keep your testing totally separate from your real code. You test with the language you are already familiar with, not VBscript like in Application Center Testing. ACT can not just test, but stress test. One computer that is remote from the server you want to test can emulate about ten users, so you need lots of computers to emulate large numbers of users. ACT doesn't automatically record HTTP calls that your application makes to other servers. Both these programs can help you monitor and answer questions, but sometimes their limitations for your particular app exist as it did for me.


At this juncture, a tool like performance monitor may become very valuable to your app. You can watch the hits happening at the same time as the garbage collection is being graphed against those hits. Memory against active sessions. Request Wait Time against hits per second.


You view a graph that is online or live from current app activity of a designated computer, or from a log that was created during an earlier scheduled time, or from a log that was created when an alert triggered its creation. Each counter is a graph. You control the graph looks, colors,  and scaling factors. Right-click the graph and choose properties to get to all these options. Most importantly you choose which counters will be logged or graphed at what frequency. I like to do live graphs so that I can introduce activity into the graph myself by using my web app and see the immediate consequence. I can maybe double the activity of one type to see that effect. Let's say I know there is a certain stored procedure run on average during a busy period every 2 seconds. I can then double that statistic by running the SP every 2 seconds myself to see the effects

Alerts cause something to occur when a certain counter reaches a value over x, or over x, y times. Then an alert has an action that occurs like, send a message to a computer, run a program, start the creation of a log of counters, or send an event to the Application Log of the Event Viewer.


Trace logs wait for an event to occur and then write to a log.


What I want to focus on here is the counter which is evaluated or measured at a regular interval instead of waiting for an event to occur.

A counter is defined by a computer, an object, a counter, and an instance and then some properties.
1) In the above image, notice that I can specify a local or remote computer
2) Next I would choose an object of interest. This is a creative area because there are so many objects to choose from. The operating system has about 40 in Windows XP. When the .NET SDK is installed it installs about 15 new objects seen in the above illustration starting with .NET CLR Data. I like the ASP.NET and ASP.NET Applications objects the best because they contain the counters seen below. See the first resource link below for details about other important objects and counters.

3) Choose a counter. Once you choose an object you can choose all counters from that object or just one or more. The only reason I would choose very many is if I was sending a log off to someone to analyze my server. They can filter the log to look at just a few things at a time, but not have to ask you to send more. To do a good job of this, I suggest using the list of objects in the first resource link below and selecting all counters for the object list and all instances for all counters. Then record every 5 seconds for ten minutes and you will have a one megabyte file after zipping to send. The difference between doing a counter log and viewing live is what you right-click to get the counter addition started. If you click the live graph and choose add counters you go live with those counters. If you right-click counter logs and choose 'new log settings', enter a log name, and then choose 'add counters' you get a log.

4) Choose which instances you want monitored, one web app or all of them together.

Let's say that from the ASP.NET Applications object, you want to look at the Anonymous Requests versus the Total Requests, and then also you want to see the Requests per Second. You would choose ASP.NET Applications object, choose Anonymouse Requests, then choose either all instances or just one application to be monitored. The importance of instances can be emphasized with the example of graphing one web app's requests against another web app. Once all four parameters are chosen you click on add. Now you may just change the counter to Total Requests and click add again. You now have two graphs and then you pick counter for Requests/Second and click add to get a 3rd graph.

The explain button next to the add button is very important though its short descriptions may seem too simple at first look. Explain tells you what the default scale is. This information is crucial. The default scaling for Request Wait Time, (the wait at IIS before processing of the request can begin), is milliseconds. If you think that because Requests per Second and some of your other counters are in seconds that Request Wait Time is you may think you have a large problem when you don't at all.


I highly recommend graphing a scaled up or detailed garbage collection as % of processor time against Requests per second to see how garbage collection reacts to your hits if you are putting objects into the session.


Watching your web application live with a meaningful set of counters can be very illuminating. All that is going on can sink in to give you great ideas for the next direction your efforts should take you in and alleviate problems before they become overwhelming.


Here are additional resources concerning the use of Performance Monitor.

Which objects/counters should one monitor for web server performance?

Q248345 How to Create a Log Using System Monitor in Windows 2000

Q313064 HOW TO: Monitor Web Server Performance by Using Counter Logs in System  

Q238145 How to Monitor Bandwidth Throttling

Q302558 HOW TO: Create and Configure Performance Monitor Alerts in Windows 2000

Q323317 HOW TO: Create an IIS Baseline by Using the Web Service Object

Q323312 HOW TO: Create an IIS Baseline by Using Log Analysis

Q323314 HOW TO: Create an IIS Baseline by Using the Memory Object

Q323315 HOW TO: Create an IIS Baseline by Using the Processor Object

Q323316 HOW TO: Create an IIS Baseline by Using the Active Server Pages Object

Q305610 HOW TO: Manage System Monitor Counters in Windows XP

Q317679 HOW TO: Create and Make Changes to a Custom Counter for the Windows

Send mail to Computer Consulting with questions or comments about this web site.
Copyright © 1996
Last modified:

User Comments

Title: required an megabyte counter   
Name: MUkesh
Date: 2007-10-21 5:24:13 AM
how can we count that how megabytes from an internet connection have been downloaded since the given time till now. like last website opened=15 kb were used, last email sent = 23 kb used, last file downloaded was of 498.5 mb etc., this type of software i require, please guide me to get this kind of software. thnx mukesh

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-25 12:04:24 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search