Today I will show you how to test a web server using Apache JMeter, a desktop application that is free and open source software, written in Java and designed to load test functional behavior and measure performance of web servers. It was originally developed to test web application but has since expanded to other test functions.
Apache JMeter may be used to test performance both on static and dynamic resources, it started as a way to test web servers but developed to a lot more protocols like SOAP, FTP, Mail servers or Database servers. It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.
You can find the latest version on the Apache JMeter download page. Since it’s written in Java all you have to do is download the binaries, decompress the archive and use it:
$ wget http://www.webhostingjams.com/mirror/apache//jmeter/binaries/apache-jmeter-2.11.tgz
$ tar zxvf apache-jmeter-2.11.tgz
$ cd apache-jmeter-2.11/bin/
In case of problems make sure you are running version 6 or higher of JAVA with the command:
$ java –v
You can find out how to install java and set environment variables here.
Optionally if you are using Debian or Ubuntu you can use apt-get to download the latest version like this:
$ apt-get install jmeter
Creating a Test Plan
When you first run JMeter it will look something like this:
First add a name to your Test Plan and then create a Thread Group by right clicking on the Test Plan and selecting from the menu Add > Threads (Users) > Thread Group
In the Thread Group settings you will have 3 important fields you will have to setup:
Number of Threads (users): This is the number of connection the application will use.
Ramp-Up Period (in seconds): The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Threads number can also be greater then ramp-up if you wish to load concurrent threads.
Loop count: How many times the process will repeat.
Next right click on the thread group and click Add > Config Element > HTTP Request Defaults
And enter the IP or hostname of the web server you wish to test in the Server Name or IP field. Now you can add HTTP requests to the Thread Group by right clicking on it and selecting Add > Sampler > HTTP Request
And just add the path of the page you want to load. You can add multiple HTTP requests for example “/” (the root of the website), “/about.html” (about page), “/download.html” (download page) and so on.
Finally add a Listener to the Thread Group that will output the results like Add > Listener > View Results in Table:
You can now the run the Test Plan using the green Start button in the toolbar and the results will be shown in the table:
You can pick from a various number of graphs and tables. You can also choice various Thread and ramp-up numbers to stress the web server as much as you wish.