Distributed Testing using JMeter & Docker (2023)

By Achini Rathnayake, Sanara Premaratne, Maheesha Lunuwila, Sameera Palansooriya, Dishan Rajapaksha

Distributed Testing using JMeter & Docker (1)

Apache JMeter is a popular open-source performance testing tool. It was first developed by Stefano Mazzocchi of the Apache Software Foundation. This is a pure Java application which designed to load test functional behavior and measure performance. JMeter also can simulate a heavy load on a server by creating tons of virtual concurrent users to web server. JMeter originally used to test web applications or FTP applications. But with the evaluation of Jmeter now it can be used for functional test, database server test.

Even though JMeter looks like a browser it works at protocol level. When we concerned about web-services and remote services it almost looks like browser, but it doesn’t perform all the actions supported by browsers. Jmeter does not execute the Javascript found in HTML pages, nor does it render the HTML pages as a browser does.

There can be instances where we need to perform a load testing If you are expecting a higher level of traffic on certain days. At such instances you need to test the loads with higher levels to simulate a larger number of concurrent users.

If you are to run a test with a larger number, you can use the Apache J-Meter, which is a Java application designed to load test functional behavior and measure the performance. Since you’ll be using the JMeter, a Master-Slave architecture can be used, where JMeter uses Java RMI [Remote Method Invocation] to interact with objects in a distributed network, which is depicted in the image below.

Distributed Testing using JMeter & Docker (2)

Here we could observe that the Server under test is the server which the application being tested is being hosted.

And instead of putting the load from a single JMeter system, the load is being put by 3 slave JMeters to the server under test. The reasons fer this distributed JMeter testing can be recognized as:

  1. Lack of hardware or infrastructural facilities to create a target load.
  2. Need to perform a load test after creating an environment which the server is getting loads from different geographical areas.

JMeter SetUp

  1. JMeter requires JVM 6 or higher. You must download and install the latest version of Java SE Development Kit
  2. Then download the latest version of JMeter Binaries zip/tgz file
Distributed Testing using JMeter & Docker (3)

3. 1. Installation is so simple. You must unzip the zip/tar file into the directory where you want JMeter to be installed. Then you are done.

4. There are 3 ways to launch JMeter:

a. GUI mode

(Video) Jmeter Docker Distributed Load Test

Windows machine — just run (double click) the file /bin/jmeter.bat to start JMeter in GUI mode

b. Server mode

Server mode is for the distributed testing. In this model, JMeter runs in server mode on server computer. And client computer it runs in GUI mode

To start the server mode, run the bat file bin\jmeter-server.bat

c. Command Line mode

jmeter -n -t testPlan.jmx — l log.xlsx -H 127.0.0.1 -P 8000

  • Jmeter -n : Jmeter is to run in command line mode
  • -t testPlan.jmx : test plan needs to be executed
  • — l log.xlsx : where to save logs
  • -H 127.0.0.1 -P 8000 : Proxy server host and port

Pre-requisites for Distributed Test

1. Ensure Java and JMeter version matches between Master (Controller) and worker machine

2. All machines are to be under the same subnet (IP address)
Eg: Controller 172.17.126.33, Worker 172.17.126.37

3. Turn off the Firewalls preferably

Set up Master Machine

1. RMI Key Generation

Go to the JMeter bin folder and make sure the below rmi attribute is set to disable in jmeter.properties file.

Distributed Testing using JMeter & Docker (4)

2. To Set up the SSL Key — certification pair, execute the create-rmi-keystore file JMeter\bin (which is a .bat file if your OS is Windows, and a .sh if you are using LINUX).

Distributed Testing using JMeter & Docker (5)

3. Create rmi-keystore file

(Video) S6E1 Learn JMeter Series - Running JMeter on Docker

Enter following information. It is recommended to provide Name — rmi and Password as — changeit

Distributed Testing using JMeter & Docker (6)

A “rmi_keystore.jks” file will be created in master server’s bin folder. Then copy the file bin/rmi_keystore.jks to every JMeter worker machine that you want to use for your distributed testing setup.

Sometimes users will experience key tool utility error When executing rmi-keystore file. Following warning message is displayed.

Distributed Testing using JMeter & Docker (7)

Solution using Command prompt would be:

Distributed Testing using JMeter & Docker (8)
Distributed Testing using JMeter & Docker (9)

4. Add remote server host ip address in user. Properties file in the bin folder

5. Run Jmeter-server file on Worker machines to start remote execution

Distributed Testing using JMeter & Docker (11)

6. Run the JMeter Test from GUI

Once controller and worker machine configurations are done, you are ready to execute JMeter Load test with distributed configuration.

All worker machine IPs are listed under Run -> Remote Start section in the JMeter UI and user can select the worker machine that need to execute script as follows:

Distributed Testing using JMeter & Docker (12)

Or else In JMeter GUI go to RUN and click Remote Start ALL as shown in below image and it will start the test with all the slave machines.

(Video) JMeter Beginner Tutorial 28 - Remote Testing | Master Slave | Distributed Testing

Distributed Testing using JMeter & Docker (13)

User can see the execution results in the Controller Machine with relevant listeners.

Distributed Testing using JMeter & Docker (14)

Successful server response while starting and ending of test can be seen as follows in the worker machine.

Distributed Testing using JMeter & Docker (15)

7. Run the JMeter script from a non-GUI Client

As an alternative, you can start the remote server(s) from a non-GUI (command-line) client. The command to do this is:

jmeter -n -t script.jmx -l listener.jtl -R HostMachineIP

Distributed Testing using JMeter & Docker (16)

User can save results in a .jtl file and can be view results using a listener

Introduction to containers and Docker

What is containerization?

Containerization is an approach to software development in which an application or service, its dependencies, and its configuration are packaged together as a container image.

Just as shipping containers allow goods to be transported by ship, train, or truck regardless of the cargo inside, software containers act as a standard unit of software deployment that can contain different code and dependencies. Containerizing software this way enables developers and IT professionals to deploy them across environments with little or no modification.

With containers, developers can focus on the development instead of the running environment. This will also get rid of the famous “works on my machine” scenario as containers will always be similar regardless of their deployed environment.

What is Docker?

Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. Docker containers can run anywhere, on your local machine, on-premise datacenter, in an external service provider or in the cloud.

(Video) JMeter tutorial 19 - How to perform Remote/Distributed Testing JMeter | Master Slave Mechanism

Docker uses a Docker-file to build a Docker image. It is a text file that contains instructions for building a Docker image. It’s like a batch script, the first line states the base image to begin with and then follow the instructions to install required programs, copy files, and so on.

Creating a Docker file containing JMeter

To run JMeter as a container, a docker file needs to be created specifying all the requirements. Each requirement can be specified as a STEP and can include features such as parameters to dynamically install dependency versions for example.

The following docker file contains the list of steps needed to install JMeter:

Distributed Testing using JMeter & Docker (17)
Distributed Testing using JMeter & Docker (18)

This docker file uses a lightweight Linux distribution called Alpine as the base for the container. It gets the JMeter version as an argument or uses the default version to download JMeter from the Apache download location. It also installs Java to the container as it is required to run JMeter.

After that, it extracts the downloaded JMeter zip file and sets that folder path as environmental variables to run the JMeter commands easily.

Finally, it sets a file called entrypoint.sh as the container entry point. Entry point file will look for any command line arguments passed to the container when running and use them to start the JMeter instance.

Distributed Testing using JMeter & Docker (19)

Running Docker containers

The above docker file can be used create containers that includes JMeter by default.

When starting the containers, command line arguments can be passed to the containers to indicate whether to run a container in the server mode or in the client mode as described above in the JMeter Setup section.

After running the containers, server container IP addresses can be given to the client container with the test file information to run the test in a distributed way.

The code for the above Docker section can be found in this GitHub repository.

Reference Links

https://jmeter.apache.org/

(Video) S6E2 Learn JMeter Series - Remote Distributed Testing in JMeter

https://www.guru99.com/introduction-to-jmeter.html

Make Use of Docker with JMeter — Learn How | BlazeMeter

FAQs

Can distributed testing is done by JMeter? ›

Distributed testing enables having a local JMeter (master) that handles the test execution, together with multiple remote JMeter instances (slaves) that will send the request to our target server. But before being able to run JMeter in a distributed way, there are a couple of simple steps you must perform.

How do you perform a distributed test in JMeter? ›

25. Apache JMeter Distributed Testing Step-by-step
  1. the firewalls on the systems are turned off or correct ports are opened.
  2. all the clients are on the same subnet.
  3. the server is in the same subnet, if 192. ...
  4. Make sure JMeter can access the server.
  5. Make sure you use the same version of JMeter and Java on all the systems.

Can Docker be used for testing? ›

Docker Hub can automatically test changes to your source code repositories using containers. You can enable Autotest on any Docker Hub repository to run tests on each pull request to the source code repository to create a continuous integration testing service.

How is Docker used in performance testing? ›

The Docker approach to virtualization can provide advantages when testing applications with open source performance testing tools. By making it replicable, performance testing with Docker containers enables sharing the tests between users and replicating the test environment.

Which testing is not supported by JMeter? ›

Answer: No, JMeter does not support the actual browser behavior. It does not render the HTML webpages as the normal browser does. The response can be viewed in HTML format but the actual timings are not present in the generated samples.

What Cannot be tested by JMeter? ›

JMeter is NOT a browser and works at the protocol level. This makes it difficult when trying to run performance tests from the user's perspective. For example, JMeter does not support JavaScript, and therefore, cannot support AJAX requests, so in this case, JMeter can only simulate HTTP traffic.

Which is better postman or JMeter? ›

I find JMeter a better fit for complexity, strong scripting, CICD inclusion, simple end-point, total load, and performance testing, allowing test re-use. Keep in mind, both tools can perform all of the above operations.

Which testing is used for distributed systems? ›

Distributed and Non-Distributed Testing

On the contrary, distributed testing means that a test consists of several parts and each of them is performed on a separate computer. However, the term “distributed” means not only a simultaneous run of tests on a number of machines, which is specific for parallel testing.

Can I run Selenium in a Docker container? ›

Setting up Docker

To run containerized selenium tests, installation of Docker is required. Follow the below steps to install and setup Docker on Windows. Download the Installer: Docker provides an installer for Windows which can be downloaded from the official docker website.

What is Docker best used for? ›

Docker is a tool designed to make it easier for developers to develop, ship, and run applications by using containers. Containers allow devs to package an application with all of its requirements and configurations, such as libraries and other dependencies and deploy it as a single package.

Is Docker good for performance? ›

Docker containers are designed to run anywhere - in an in-house data center, the cloud, or a hybrid and multi-cloud environment. Out of the box, Docker containers tend to outperform other virtualization methods, but they can be further optimized to offer even better performance.

What are the three main components of Docker? ›

There are three parts to the Docker Engine: Server: The Docker daemon (dockerd) is in charge of creating and managing containers. Rest API: The Rest API enables the communication between applications and Docker and gives Dockerd instructions. Command Line Interface (CLI): Docker commands are executed using the CLI.

Is Docker an automation tool? ›

Docker is a tool that is used to containerize the applications for automated deployment. Containerization creates light-weighted, isolated applications which run efficiently on any platform without any separate configuration.

Which tool is better than JMeter? ›

Loadrunner from Micro Focus is a widely used Load Testing tool. It is one of the best alternatives to JMeter that offers a user-friendly monitoring and analysis interface with colored charts and graphics. Features: Supports continuous testing.

What are the disadvantages of JMeter? ›

Disadvantages of JMeter

It doesn't support JavaScript and AJAX requests. Complex applications that use dynamic content or use JS to alter requests can be difficult to test using JMeter. It's difficult to get data from one place or to perform customizations.

Which is best Selenium or JMeter? ›

The main difference between JMeter and Selenium is that JMeter is best for load and stress testing while Selenium offers full test automation and cross-browser testing. Read on to learn more about the differences!

Is JMeter outdated? ›

While JMeter is considered old technology, it is still being developed and enhanced in line with technology changes.

Which language is used in JMeter? ›

The Groovy language is used as a scripting language for JMeter. When it comes to improving JMeter's functionality, Groovy has proven to be a powerful, and yet lightweight, language in terms of performance.

Is JMeter the best performance testing tool? ›

Performance Testing is an integral part of any software or web application today. It is of utmost importance to know if the application will bear the load or crash in different scenarios and on different platforms. And the most outstanding tool used to do so is the JMeter.

Is learning JMeter is difficult? ›

Friendly GUI: JMeter is extremely user-friendly therefore easy to use and doesn't take time to get familiar with it. Full multithreading framework. JMeter allows concurrent and simultaneous sampling of different functions by a separate strand group.

Does JMeter need JDK or JRE? ›

Because JMeter uses only standard Java APIs, please do not file bug reports if your JRE fails to run JMeter because of JRE implementation issues. Although you can use a JRE, it is better to install a JDK as for recording of HTTPS, JMeter needs keytool utility from JDK.

Why JMeter is better than LoadRunner? ›

In addition to easier configuration of elements, JMeter doesn't require adding beginning or ending transaction elements, which LoadRunner does. In LoadRunner, arranging scripts takes up more time and resources, and it is more complex because it requires managing different agents.

What are the four 4 types of systems tests? ›

There are four main stages of testing that need to be completed before a program can be cleared for use: unit testing, integration testing, system testing, and acceptance testing.

What are the 4 types of testing data? ›

Some of the types of test data included in this method are valid, invalid, null, standard production data, and data set for performance.

How many types of JMeter are there? ›

JMeter has two types of Controllers: Samplers and Logical Controllers. These drive the processing of a test. Samplers tell JMeter to send requests to a server. For example, add an HTTP Request Sampler if you want JMeter to send an HTTP request.

Which tool is best for performance testing? ›

Top Performance Testing Tools
  • WebLOAD.
  • LoadNinja.
  • HeadSpin.
  • ReadyAPI Performance.
  • LoadView.
  • Keysight's Eggplant.
  • Apache JMeter.
  • LoadRunner.
25 Oct 2022

What is distribution testing? ›

Distribution tests are hypothesis tests that determine whether your sample data were drawn from a population that follows a hypothesized probability distribution. Like any statistical hypothesis test, distribution tests have a null hypothesis and an alternative hypothesis.

Can you run GUI apps in a Docker container? ›

Running a GUI program in Docker can be a useful technique when you're evaluating a new piece of software. You can install the software in a clean container, instead of having to pollute your host with new packages. This approach also helps you avoid any incompatibilities with other packages in your environment.

Why is Docker used in automation? ›

Docker is a Platform as a Service that provides OS-level virtualization. It makes it easy to create, deploy, and run applications using containers. Containers act as a freshly installed OS, each with its own software, libraries, and configurations. They communicate with each other through well-defined channels.

Is Docker good for web apps? ›

Docker is very useful for web applications running on a server or console-based software. But if your product is a standard desktop application, especially with a rich GUI, Docker may not be the best choice.

Where is Docker mostly used? ›

Docker is an open-source containerization platform used for developing, deploying, and managing applications in lightweight virtualized environments called containers. It is mainly used as a software development platform for developing distributed applications that work efficiently in different environments.

Which problem is solved by Docker? ›

Docker is a platform that allows developers to containerize and easily ship software. It helps eliminate the overhead of configuring environments to run software by, essentially, shipping the environment along with your code. This is often explained using the shipping container analogy.

What should you not use Docker for? ›

Docker is great for developing web applications, but if your end-product is a desktop application, then we would suggest you not to use Docker. As it doesn't provide the environment for running the software with a graphical interface, you would need to perform additional workarounds.

Is Docker faster than a VM? ›

Docker containers are generally faster and less resource-intensive than virtual machines, but full VMware virtualization still has its unique core benefits—namely, security and isolation.

Does Netflix use Docker? ›

We implemented multi-tenant isolation (CPU, memory, disk, networking and security) using a combination of Linux, Docker and our own isolation technology. For containers to be successful at Netflix, we needed to integrate them seamlessly into our existing developer tools and operational infrastructure.

Which is better VM or Docker? ›

This means Docker containers are much smaller and require far fewer resources than a VM. Docker is fast. Very fast. While a VM can take an at least a few minutes to boot and be dev-ready, it takes anywhere from a few milliseconds to (at most) a few seconds to start a Docker container from a container image.

How many containers can Docker run? ›

Using this simple calculation, we can estimate that we can run about 1,000 containers on a single host with 10GB of available disk space.

Which are the two types of Docker clients? ›

The Docker Engine

The Docker daemon constantly listens for Docker API requests and processes them. Docker Engine REST API: An API used by applications to interact with the Docker daemon; it can be accessed by an HTTP client. Docker CLI: A command line interface client for interacting with the Docker daemon.

What skills do you need for Docker? ›

Skills and Qualifications:

Experience with container networking on Docker. Experience with application deployment by using CI/CD. Experience with monitoring tools like Prometheus, Grafana, Datadog, etc. Experience with alerting tools like OpsGenie, PagerDuty, etc.

Which is better Jenkins or Docker? ›

Docker Swarm is more comprehensive and highly customizable, whereas Jenkins is customizable with the help of plugins. Kubernetes and Jenkins provide low fault tolerance unlike Docker. Docker is a container engine that can make and handle containers, whereas Jenkins is a CI/CD model that can build and test applications.

What big companies use Docker? ›

Who uses Docker?
CompanyWebsiteCompany Size
Dailymotion SAdailymotion.com500-1000
California State University-Stanislauscsustan.edu1000-5000
NetSuite Incnetsuite.com>10000
Red Hat Incredhat.com>10000
1 more row

Is Docker only for DevOps? ›

The Docker tool was designed for developers and system administrators, an essential part of DevOps. With Docker, developers can focus on application development rather than being worried about the platform where it will run. They can start all by themselves using ready-to-use Docker programs.

What are top 10 benefits of Docker? ›

The answer is, Containerizing programs have a variety of advantages which include:
  • Portability Across Machines. You may deploy your containerized program to any other system that runs Docker after testing it. ...
  • Rapid Performance. ...
  • Lightweight. ...
  • Isolation. ...
  • Scalability. ...
  • Docker Hub. ...
  • Docker Store. ...
  • Docker Image.
21 Jun 2022

What is Docker with real time example? ›

In general, a Docker image is a set of layers that serve for code execution in a Docker container. In other words, it is a template for running your containers. With it you can have a number of them based on a single image. An image comprises a Docker file, system libraries, dependencies, tools, and settings.

Is Docker used nowadays? ›

Containers were just the Beginning

For millions of developers today, Docker is the de facto standard to build and share containerized apps – from desktop, to the cloud.

What type of tests can be done using JMeter? ›

The Apache JMeter is an open-source, purely Java-based software. The software is used to perform performance testing, functional testing, and load testing of web applications. It is used to test load testing functional behavior and measuring performance.

How do you test a distributed system? ›

How do you test your distributed system?
  1. Unit test: testing the classes and the code.
  2. Integration test: testing a service with its attached resources.
  3. End to end/ functional test: testing how different system components and services work together.
13 Jun 2018

Which type of performance can be tested using JMeter? ›

Apache JMeter may be used to test performance both on static and dynamic resources, Web dynamic applications. 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.

What are the three types of system testing? ›

Unit Testing used to test a single software; Integration Testing used to test a group of units of software, System Testing used to test a whole system and Acceptance Testing used to test the acceptability of business requirements.

Why do we do distributed testing? ›

Distributed Testing is a kind of testing which use multiple systems to perform Stress Testing. Distributed testing is applied for testing websites and server applications when they are working with multiple clients simultaneously.

What are the best examples of distributed systems? ›

Examples of Distributed Systems
  • Networks. The earliest example of a distributed system happened in the 1970s when ethernet was invented and LAN (local area networks) were created. ...
  • Telecommunication networks. ...
  • Distributed Real-time Systems. ...
  • Parallel Processing. ...
  • Distributed artificial intelligence. ...
  • Distributed Database Systems.

Is JMeter a functional testing tool? ›

Apache JMeter is open source software, a 100% pure Java desktop application designed to load test functional behavior and measure websites' performance. It was originally intended for load testing for web applications, but it has expanded its two other test functions.

Do we need coding for JMeter? ›

The major important thing is for JMeter is that there is no need to have any coding skills. Advantages of JMeter API: Open source. Quick API testing.

Videos

1. Distributed Load testing - JMeter Tutorial 21
(HelpingTesters)
2. PerfBits - JMeter in Docker
(PerfBytes)
3. Distributed Testing By Jmeter
(su su)
4. S6E3 Learn JMeter Series - Remote Distributed Testing in JMeter in AWS
(QAInsights)
5. DDOS as a Service': (JMeter, Docker and AWS) - Evertson Croes [Luminis DevCon 2018]
(Luminis)
6. S2E10 Learn Locust Series - Distributed Load Testing in Docker
(QAInsights)
Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated: 03/23/2023

Views: 5460

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.