Advanced stress testing with Application Center Test

At work I am facing a challenge of testing how many websites can be hosted on a single server. As you never know the real circumstances that real world websites and users create, you have to make some assumptions for such a test to make sense. In this case we know that all the sites will be variations from the same original site, so we will just use this site for testing. Regarding traffic patterns we are lucky enough to have real world logfiles from similar websites that we can use.

After spending most of my working hours trying to understand what goes on under the hood of websites (mainly ASP.Net, but 99% is HTTP requests anyway), I have learned not to care so much about simultaneous users and just cut to the bone by answering the question “… and how many requests is that per second”. From my experience the webserver do not care much if 10 users clicks once a minute or 5 users click every 30 seconds. To make a long story short, we are going to use LogParser from Microsoft to find the average number of requests per second during peak hours from these logfiles. This will give me a number of requests per second (minute or hour, whatever) PER website.

Say a website receives 2 requests per minute, and I want to stress test 17 identical websites. Overall this will be 1765 milliseconds between each request. But what is the best way to test if this performs fine? Well, I have been looking at Microsofts “Application Center Test” (ACT) made for the purpose.   ACT has a nice feature where I can record clicks in a browser and save it in vnscript files. However, having to click in 17 different (but identical sites) seems just too tiresome. And what do I do when I later on want to test with 34 identical sites, and how do I get it right with the 1765 milliseconds? Not to think of the sizes of these vbscript files.  

Then it hit me: vbscript = programming language. Work smarter, not harder. So I recorded a sample script, and manipulated it into a highly dynamical one. It has two arrays, one with the list of host names and another with a list of the relative urls we are going to test. It also has a delay that i can set to anything I want e.g. 1765 milliseconds (later on I might want to make the number random around an average number to make it more realistic. The script then just picks a random domain and a random url at each request to simulate real life traffic. I think it is kinda neat. The script goes here:

Option Explicit
Dim fEnableDelays
fEnableDelays = true

Sub SendRequest1(p_domain, p_url, p_delay)
    Dim oConnection, oRequest, oResponse, oHeaders, strStatusCode
    If fEnableDelays = True then Test.Sleep (p_delay)
    Set oConnection = Test.CreateConnection(p_domain, 80, false)
    If (oConnection is Nothing) Then
        Test.Trace “Error: Unable to create connection to ” & p_domain
    Else
        Set oRequest = Test.CreateRequest
        oRequest.Path = p_url
        oRequest.Verb = “GET”
        oRequest.HTTPVersion = “HTTP/1.1”
        set oHeaders = oRequest.Headers
        oHeaders.RemoveAll
        oHeaders.Add “Accept”, “image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*”
        oHeaders.Add “Accept-Language”, “en-us”
        oHeaders.Add “Accept-Encoding”, “gzip, deflate”
        oHeaders.Add “User-Agent”, “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)”
        oHeaders.Add “Host”, “(automatic)”
        oHeaders.Add “Cookie”, “(automatic)”
        Set oResponse = oConnection.Send(oRequest)
        If (oResponse is Nothing) Then
            Test.Trace “Error: Failed to receive response for URL to ” + p_url
        Else
            strStatusCode = oResponse.ResultCode
        End If
        oConnection.Close
    End If
End Sub
Sub Main()
 dim arDomain, arUrl
 dim i, delay
 dim domainIndex, urlIndex
 dim ubounddomain, uboundurl

 delay = 500
 arDomain = Array(“
www.mysite.net“)
 arUrl = Array(“/product.aspx”, “/customers.aspx”, “/parners.aspx”)
 ubounddomain = ubound(arDomain)
 uboundurl = ubound(arUrl)
 
 randomize()
 for i = 0 to 30
  domainIndex=Int((ubounddomain) * rnd())
  urlIndex=Int((uboundurl) * rnd())
  call SendRequest1(arDomain(domainIndex), arUrl(urlIndex), delay)
 next
   

End Sub
Main

When I set the delay to 500 milliseconds and run it with 2 simultaneous users, I can see the graph flatlining around 4 requests per second, which is exactly as expected. So to add more sites I just need to add the extra domains and adjust the delay to simulate the extra stress.

Happy testing 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: