Apache JMeter, a desktop application that is free and open-source software, written in Java and designed to load test functional behavior and measure the 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.
In this article, I will show how to install Apache JMeter on Linux distributions CentOS and Ubuntu, and go through the basics on how to use JMeter.
Install JMeter on Linux Distributions
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.
To install on CentOS/Redhat:
$ 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/ $ ./jmeter
To install on on Ubuntu/Debian use apt-get:
$ apt-get install jmeter
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.
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.