Load & Stress Testing

By | 20/04/2014

Stress testing your web server is very important, if you are planning a new environment or a new launch, stress test will able you to know your site limits and prevent unnecessary downtime at critical time. Bench marking can be done by yourself or using third party cloud services. In this post I’ll give you a quick summery of tools that can be a good starting point.

Linux Tools

I recommend to start with one of those two free and easy to use tool, each of them has its own benefits and both of them can cover most of the common scenarios.

Siege

Siege Installation

sudo apt-get install siege

Or download the latest version from http://www.joedog.org/siege-home/

Example 1

siege -c10 -r20 –b http://www.mydomain.com/ 

This command will run a benchmark test on http://www.mydomain.com, with 10 concurrent users with 20 requests per each.
Example 2

Siege -c10 –r20 –i -f urls.txt –t 1H

This is a bit more advance usage, in this case you will randomly (-t) load the urls (-f) from “urls.txt” and execute the test for 1 hour For more information, check siege manual from the official web site http://www.joedog.org/siege-manual/ When siege test is done, you will receive a results report.

Apache Benchmark

AB installation

sudo apt-get install apache2-utils

Example 1

ab -n 100 -c 10 http://www. mydomain.com/

This request will run a benchmark test ON http://www.mydomain.com, 100 requests, with a maximum of 10 requests running concurrently. If you wish to simulate it more too real browsers, you can add –k flag to enable keep-alive.

Example 2

ab -p post.txt -c 10 -n 100 –r http://www.mydomain.com/

This is an example of loading your server with POST requests. You can save the required request in txt file and upload in to the machine. Then execute the test with the required data. If you wish to visualize and analyze your results, you need to use “-g” command-line parameter to write a “gnuplot TSV” file and then upload to – https://loadosophia.org
Full options list can be found at http://httpd.apache.org/docs/2.2/programs/ab.html

Example Report

Load Test Report Example

image from http://loadosophia.org/

Windows Tools

LoadUIWeb

If you wish to stress test from windows, or looking for record user activities and then reproduce it with multiple users, it can be done by LoadUIWeb (loaduiweb.org). LoadUIWeb is a free desktop tool for performance, and stress testing web applications. You can record your scenarios and then execute a test that can include several scenarios, each one executed by different number of agents.

Apache JMeter (both for Windows and Linux)

Apache JMeter™ desktop application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. JMeter is very powerful tool, and in this post I only describe the basic functionality (I will write a more detailed post in the future). Download the latest version from https://jmeter.apache.org/download_jmeter.cgi. To open JMeter run “/bin/ jmeter.bat”  You can manually create your test plan. I’m using a Blaze Meter chrome extension that records all the traffic and creates a jmx file I only load. Once the test plan is ready, you need to configure the “Thread Group”. there you define the number of users you wish to simulate, it can be all in once or increasing number (Ramp-up) and the number of loops, if any.
To get log results you need to add listeners, I recommend those two.  Right click on Thread Group Add -> Listeners > Aggregate Graph View Results Tree   Once it all ready, press the green play button and start testing. It’s not recommended to have more than 100 users on each server, but it depends on the hardware you using.

a nice video tutorial: http://blazemeter.com/jmeter-training/getting-started-jmeter

Test from the Cloud

If you don’t wish to execute those tests from your machines, quick Google search will give you hundreds results for stress testing service providers. I personally like http://loader.io/ because they give up to 10,000 requests for 1 minute test. By the end of the test you will receive a full detailed report. Another recommended site is http://blazemeter.com/ you can record your scenario with their chrome extension Blaze Meter chrome extension and then upload it to their site, define your test (you get 50 users for free) andit will be executed by their servers and you will be informed by email once it ready.

Summery

this post is a good staring point to see the available tools to start with. With each tool there are more configurations available, able to get much more then the simple examples in the blog.

I strongly recommend to start with something. When you start testing you site you will get a better picture on what your system can or cannot do. Those are pretty simple tools, so you can start right away. Test your site, know your limits and prepare accordingly!

Leave a Reply

Your email address will not be published. Required fields are marked *