Setting up a JMeter Cluster for web server load testing

Setting up a JMeter Cluster for web server load testing

Setting up a JMeter Cluster for web server load testing

This tutorial shows you how to set up a JMeter cluster for load tests. Like anyone who doesn’t know it yet, the Apache JMeter application is open source software, a 100% pure Java application designed to test functional behavior and measure performance. It was originally developed for testing web applications but has since expanded to other test functions. 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.if(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-howtoforge_com-box-3-0’)};

But as each business approach becomes larger and larger, engineers and testers need to perform more testing to ensure that each expansion module can serve larger consumers without compromising daily production operations. To ensure this, JMeter has introduced its own services by being able to test the performance test under larger environments by performing it as a clustering process.if(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-howtoforge_com-medrectangle-3-0’)};

In the event that your JMeter client computer is unable to simulate enough users to load your server, or is limited at the network level, you can control multiple remote JMeter engines from a single JMeter client. By running JMeter remotely, you can replicate a test on many low-end computers and simulate a larger load on the server. An instance of the JMeter client can control any number of remote JMeter instances and collect all data from them.

Distributed testing is a type of testing in which multiple systems are used to perform stress tests. Distributed testing is used to test Web sites and server applications when they work with multiple clients simultaneously.

1. How does it work

If we are running our load tests locally with single JMeter application, there are certain limitations to the number of users you can run, even if your computer has enough CPU and memory. Due to that, how can we create a scenario with more than 1000 concurrent users using JMeter? Due to this scenario, the idea of JMeter in distributed mode comes in picture.

When we talk about distributing JMeter, we refer to a Master-Slave architecture where JMeter uses Java RMI [Remote Method Invocation] to interact with objects in a distributed network. Below pictures are to summarize the workflow:

By using JMeter under cluster design, you can ensure your testing enable for having a local JMeter (master) that handles the test execution, together with multiple remote JMeter instances (slaves) that will send the request to your target server.

Connection to JMeter cluster / JMeter service can be made via:

  1. JMeter desktop application
  2. SSH / terminal
  3. VNC
  4. API service endpoint (WIP)

if(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-howtoforge_com-medrectangle-4-0’)};

2. Installation Phase

For the installation phase, first we’ll list out the inventory of what each server will be. Below are the details:

System Inventory







CentOS 7 x64 bit

JMeter server 01 (master/slave)



CentOS 7 x64 bit

JMeter server 02 (slave)



CentOS 7 x64 bit

JMeter server 03 (slave)



CentOS 7 x64 bit

JMeter server 04 (slave)


Now let’s get our hands dirty, we will start by setting up the server with prerequisites, assuming each server are under minimal server configuration. Below are the steps:

 [[email protected] /]# yum install -y wget initscripts net-tools 

Doing above is optional, just to ensure our installation and review work smoothly. Once installation done, you’ll have the screenshot like below

Next, we need to install Java packages as it’s compulsory for setting up JMeter as a service. Below are the steps:

 [[email protected] /]# wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" "" 
[[email protected] /]# yum localinstall -y jdk-8u131-linux-x64.rpm

Process will be like below:

Next, we will install the JMeter packages. In this tutorial, I will use the current stable version for JMeter installation. The steps are like below:

 [[email protected] /]# wget 
[[email protected] /]# tar -zxf apache-jmeter-5.1.1.tgz
[[email protected] /]# ln -s /apache-jmeter-5.1.1 $HOME/jmeter
[[email protected] /]# echo "export JMETER_HOME=$HOME/jmeter" >> /root/.bashrc
[[email protected] /]# echo "export PATH=$PATH:$JMETER_HOME/bin" >> /root/.bashrc
[[email protected] /]# source /root/.bashrc
[[email protected] /]# curl -L > $HOME/jmeter/lib/ext/plugins-manager.jar
[[email protected] /]# curl -L > $HOME/jmeter/lib/cmdrunner-2.2.jar

Once everything’s done, you will see the progress like shown below

Next, we will use a plugin manager to help to install several java packages needed for our JMeter to run smoothly. Below are the steps:

 [[email protected] /]# java -cp $HOME/jmeter/lib/ext/plugins-manager.jar org.jmeterplugins.repository.PluginManagerCMDInstaller 
[[email protected] /]# /root/jmeter/bin/ install jpgc-autostop,jpgc-casutg,jpgc-csl,jpgc-dummy,jpgc-ffw,jpgc-filterresults,jpgc-functions,jpgc-json,jpgc-mergeresults,jpgc-prmctl,jpgc-sense,jpgc-tst,jpgc-wsc

If the progress run smoothly, you’ll get as per screenshot below

Now as everything is done on installation part, you will need to create the keystore prior to starting JMeter as slaves. To do this, we can use script that bundle with Apache JMeter packages called . Below are the steps :-

 [[email protected] ~]# $HOME/jmeter/bin/

Below are the screenshot

Now pretty much we’ve done for JMeter installation, we can proceed to make configuration in JMeter service for distribution process. You can continue setup the rest of JMeter server as same installation you’ve made for this server.

3. Configuration Phase

Now as for the configuration to make as distributed JMeter, we just need to edit the inside JMeter /bin folder as per below

 [[email protected] ~]# vim /root/jmeter/bin/ remote_hosts= , , , 

Notice that I’ve added all our JMeter server into JMeter configuration file. By default the configuration is stated as remote_hosts= .For this configuration, you just need to configure it under JMeter server that assign as Master

4. Testing Phase

As everything is done, let’s do test and compare results for single JMeter load testing and distributed JMeter load.

Before we start the test, let’s make the assumption for final result expection. For this test, we will try to execute a database query that called from a site. We will use the URL to access the site and include it inside JMX file to be executed by JMeter service. For this tutorial, we will not include the step on how to create a JMX file

Just to be clear, below are the simple query that we’ll use execute from database via web URL:

 [[email protected] ~]# mysql -u shahril -p -h 
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 546695
Server version: 5.7.20-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> SELECT 1 FROM cassie_devdb.saml_users WHERE (username = '[email protected]') LIMIT 1;
| 1 |
| 1 |
1 row in set (0.00 sec)

FYI, you can use any query you like for this tutorial. As this query was not tune, it is expected to boost CPU resources when it’s been executed by multiple session which we will schedule using JMeter service

Now as everything prepared and understood, let’s start all JMeter server. Below are the command:

 [[email protected] ~]# $HOME/jmeter/bin/jmeter-server & 
[1] 6149

To proceed with the test, let’s execute the JMX file that will trigger above query in single JMeter server as per below:

 [[email protected] /]# /root/jmeter/bin/jmeter -n -t /opt/jmeter/shahril_loadtest/testing.jmx 

Notice above `testing.jmx` was the JMX file that contain the execution thread. Once above executed, you will see result as per screenshot below

Next, let’s run the same JMX file towards JMeter in distributed environment. Below are the steps:

 [[email protected] /]# /root/jmeter/bin/jmeter -n -t /opt/jmeter/shahril_loadtest/testing.jmx -R,,, 

Noted that the command fairly same with running in single phase, just need to add a flag of -R and added the other JMeter server to be included for execution. You can see the detail of listed flag provided by JMeter command as below:

 [[email protected] /]# /root/jmeter/bin/jmeter --help 
_ ____ _ ____ _ _ _____ _ __ __ _____ _____ _____ ____
/ \ | _ \ / \ / ___| | | | ____| | | \/ | ____|_ _| ____| _ \
/ _ \ | |_) / _ \| | | |_| | _| _ | | |\/| | _| | | | _| | |_) |
/ ___ \| __/ ___ \ |___| _ | |___ | |_| | | | | |___ | | | |___| _
/_/ \_\_| /_/ \_\____|_| |_|_____| \___/|_| |_|_____| |_| |_____|_| \_\ 5.1.1 r1855137

Copyright (c) 1999-2019 The Apache Software Foundation

To list all command line options, open a command prompt and type:

jmeter.bat(Windows)/ -?


To run Apache JMeter in GUI mode, open a command prompt and type:

jmeter.bat(Windows)/ [-p property-file]


To run Apache JMeter in NON_GUI mode:
Open a command prompt (or Unix shell) and type:

jmeter.bat(Windows)/ -n -t test-file [-p property-file] [-l results-file] [-j log-file]


To run Apache JMeter in NON_GUI mode and generate a report at end :
Open a command prompt (or Unix shell) and type:

jmeter.bat(Windows)/ -n -t test-file [-p property-file] [-l results-file] [-j log-file] -e -o [Path to output folder]

To generate a Report from existing CSV file:
Open a command prompt (or Unix shell) and type:

jmeter.bat(Windows)/ -g [csv results file] -o [path to output folder (empty or not existing)]


To tell Apache JMeter to use a proxy server:
Open a command prompt and type:

jmeter.bat(Windows)/ -H [your.proxy.server] -P [your proxy server port]


To run Apache JMeter in server mode:
Open a command prompt and type:



Moving on, once the JMX file been executed under distributed environment, you will see result as per screenshot below

Great, now we’ve successfully run our test in both environment phase. To see the comparison differences, I’ve set up a monitoring dashboard powered by grafana .As this is just to show the result differences, we will not cover on how to setup Grafana as monitoring dashboard

Base on the CPU usage that taken from the target server that host our website, below are the result under single JMeter thread:

And below image are the result under distributed JMeter thread:

Clearly from above comparison, we can see that we manage to introduce more thread to be executed into the target server to see the limitation of an application can accept.

About the Author

Leave a Reply