It is becoming a must to build a nice shiny blog for events, conferences, etc – those blogs act as the backbone of the social media campaign and as the aggregator of content being shared through the day.
This type of blogs usually have traffic peaks happening mostly during limited hours, so If you want to avoid users bitching about your site being down just when they need it – you need to be prepared by doing something called: Load Testing
Load testing is the process of putting demand on a system or device and measuring its response. It is performed to determine a system’s behavior under both normal and anticipated peak load conditions.
It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation.
So by performing load testing, you will be able to perform necessary tweaks to improve performance or purchase more processing capacity to match your number of visitor expectations.
By using woopra.com, you can live monitor the number of visitors and their activity on your site and use your previous load testing statistics to predict and avoid the bottlenecks by shifting user attention, shifting content or activating optimization techniques like loading a light weight theme or only part of your content.
Woopra offers a free version on woopra.com – it is pretty straight forward and intuitive to set up an account and start live monitoring your users (and even live chatting with them) – so i won’t go over the details here, if you are facing any problems, I am sure the guys from @woopra can help.
Performing the load test:
I previously wrote a blogpost on Load testing where I introduced the most 2 famous tools to use: HP Loadrunner (commercial) and JMeter (Free open source)
You can read the full post here : http://mireille.it/load-testing-with-jmeter/
Since then JMeter became my favorite tool – it is free/open source and really nice when you get the hang of it
You can grab your free copy from here . The thing is 5.3 MB only.
Browse to your newly downloaded folder, go to bin and double click jmeter.bat
Linux distro / OSX
If you are on some linux distro or osX you have a jmeter.sh file . Browse to your newly downloaded folder, open it in your favorite editor – there is one line that says :
java $JVM_ARGS -Dapple.laf.useScreenMenuBar=true -jar `dirname $0`/Applications/jakarta-jmeter-2.3.4/bin/ApacheJMeter.jar “$@”
All you need to do is make sure to point the dirname to your correct download location
After that you launch it in your terminal and JMeter java GUI will come to show.
Creating Thread Group
Right click on Test Plan , click add >>> Thread group
Thread group elements are the beginning points of any test plan. All controllers and samplers must be under a thread group.
Now you get to specify the following elements :
Thread name : descriptive field – we will name it “Thread group_testing wordpress”
Comments : descriptive field
- Action taken after sampler error :
- Stop thread
- Stop test
- Stop test now
- Number of threads users u are emulating ( how many users visiting ur site u want )
- Ramp up period ( the time JMeter takes to generate all the threads – if you have 10 threads and ramp up period of 100 secs – JMeter will start a thread each 100/10 = 10 secs. after 100 secs, all your threads will be booted )
- Loop Count : How many times you want to repeat your test – you have the forever option or a number u can enter
After specifying the parameters for your thread group “testing wordpress”, time to emulate your first http request.
Creating HTTP Request
Right click on “testing wordperss” thread group >>> add >>> sampler >>> HTTP Request
( as you can see there are tons of other requests you can add like FTP , SMTP, JDBC – aka you can emulate people asking for file transfer, mail, db connections ! neat – but won’t be covered in this tutorial )
After choosing HTTP Request you need to specify the following details :
- Name/comment of request : anything descriptive
- Server Name or IP : in my case mireille.it or <insert your blog name>
- Path : / in case u were planning on testing the root or any relative page link
- Port Number : 80 (default port for browsing)
- Method : get - post – head – put – options – trace – delete – you will need to choose “GET”
You can add as many HTTP Request as you want – like this you can emulate the user visiting many pages in some special order – you can also emulate the user viewing a video for example by adding an HTTP request to yourwebsite.com/video.flv for example.
An interesting thing is that you can add a delay between the different actions – so if you added
HTTP Request 1 : index page
HTTP Request 2 : About us
HTTP Request 3 : watch video
You can add a time delay between each action to emulate the user actually spending time on the page.
Another Interesting thing you can do is that you can emulate users logging in for example or sending any kind of parameters like searches – all you have to do is add parameters to your requests.
Right click on your Thread Group >> Add >> Sampler >> HTTP Request
In path you can add the path to your login/protected page
In Parameters – you can add as many parameters as you want – it works on all kind of forms – all you have to do is know the “name” of the field being submitted – which largely depends on your blog.
In wordpress, the username field is called “username” – password field is called “password” – if you are testing out a contact form, you need to see the name you created in the plugin and so on.
Here is an example i filled out
as you can read on – it is pretty easy to fill out – now you need to know if the form is actually submitting and if the request is being carried on.
You need to create an Assertion that allow the ability to assert facts about responses received from the server being tested. Using an assertion, you can essentially “test” that your application is returning the results you expect it to.
In this case we “Assert” if the reply sent back from the server is “successful login” – Here is a sample assertion I created
Right click on the specific request you want to assert >> Add >> Assertions >> Response assertion – you will be greeted by the following screen
The returned page is supposed to have the word “success” – which in this test i know it does.
You still need to view statistics about your assertions – so you right click on your HTTP Request >> Add >> Listener >> Assertion results- you only have to name it and make sure to check “Log errors only” – uncheck “Log successes”.
Depending on what you check, you will get a simple log of the errors or the successful logins.
Here is an example of a logged error
When i ran the test – i told JMeter to expect the word “epic” in reply – which was not the case and the “assertion” was deemed false.
This is basically what you need to do to perform the test, now time to get the data out by adding some reports.
Adding the Reports:
Reports are what it all comes down to and is actually what you will use to build your analysis.
Reports are the “listeners” – you can right click on individual requests or on the whole Thread and add a report to it, some reports are tables, others are graphs, almost all of them can be saved into a file – which comes in very handy.
The next step is to use common sense and simple math the analyze the above data and graphs and deduct your performance benchmark.
The nice thing about JMeter is that once you are done, you can save the scripts for later use and easy modification – all you have to do is replace couple of values and you are set to load test many blogs without re-doing the work or having to re-record screens and steps.
I think that makes it a long enough post – if you need a hand load testing your blog, drop me an email using the contact form, I will be glad to give a hand since this is one of the “services” I can offer as a freelancer.