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()
Public Sub StartTimer()
StartTime = Environment.TickCount
ReadOnly Property MilliSecondsElapsed() As Double
Return (Environment.TickCount - StartTime)
ReadOnly Property SecondsElapsed() As Double
Return MilliSecondsElapsed / 1000
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)
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.