1. Overview
1.概述
In this article, we’ll explore distributed performance testing using JMeter.
在这篇文章中,我们将探讨分布式使用JMeter进行性能测试。
2. What Is Distributed Performance Testing?
2.什么是分布式性能测试?
Distributed performance testing means using multiple systems with the master-slave configuration to test a web application or a server’s performance.
分布式性能测试是指使用主从配置的多个系统来测试一个网络应用程序或服务器的性能。
In this process, we’ll use a local client as a master that handles the test execution using multiple remote clients, and each remote client acting as a slave will execute the test on our target server.
在这个过程中,我们将使用一个本地客户端作为主站,使用多个远程客户端处理测试执行,每个远程客户端作为从站将在我们的目标服务器上执行测试。
Each slave system executes the load tests following the exact condition set by the master. Therefore, the distributed performance testing helps us achieve a higher number of concurrent users requesting the target server.
每个从属系统都按照主系统设定的确切条件执行负载测试。因此,分布式性能测试有助于我们实现更多并发用户对目标服务器的请求。
In simple terms, the outline of the distributed performance testing using JMeter will look like:
简单来说,使用JMeter进行分布式性能测试的大纲会是这样的。
3. Setup
3.设置
3.1. Prerequisites
3.1.先决条件
We should follow a few prerequisites for a smooth setup and test run:
我们应该遵循一些先决条件,以实现顺利的设置和测试运行。
- Multiple computers with JMeter installed on each
- Firewalls on the systems are turned off, or required ports are opened for connection
- All systems (master/slave) are on the same subnet
- JMeter on each system can access the target server
- Use the same version of Java and JMeter on all systems (master and slave)
- For simplicity, disable the SSL for RMI
Now that we have our systems ready, let’s configure the slave and master systems.
现在我们已经准备好了我们的系统,让我们来配置从属和主系统。
3.2. Configure the Slave System
3.2.配置从属系统
On the slave system, we’ll go to the jmeter/bin directory and execute the jmeter-server.bat file on Windows. Or, we can run the jmeter-server file on Unix.
在从属系统上,我们将进入 jmeter/bin目录,在Windows上执行jmeter-server.bat文件。或者,我们可以在Unix上运行jmeter-server文件。
3.3. Configure the Master System
3.3.配置主系统
On the master system, we’ll go to the jmeter/bin directory and edit the remote_hosts property in the jmeter.properties file to add IP addresses (comma-separated) of the slave systems:
在主系统上,我们将进入jmeter/bin目录,编辑jmeter.properties文件中的remote_hosts属性,添加从属系统的IP地址(以逗号分隔)。
remote_hosts=192.165.0.10,192.165.0.20,192.165.0.30
Here, we’ve added three slave systems.
在这里,我们已经添加了三个从属系统。
So, by starting the JMeter (master) in the GUI mode, we can confirm all the slaves listed in the Run > Remote Start option:
因此,通过在GUI模式下启动JMeter(主站),我们可以确认Run > Remote Start选项中列出的所有从站。
That’s it! We’re ready to start the JMeter master system to execute tests on the target server using multiple clients.
这就是了!我们准备启动JMeter主系统,使用多个客户端在目标服务器上执行测试。
4. Remote Testing
4.远程测试
For remote testing, we can run JMeter in GUI mode for simplicity. However, we should run it using CLI mode when performing actual tests.
对于远程测试,为了简单起见,我们可以在GUI模式下运行JMeter。但是,在进行实际测试时,我们应该使用CLI模式来运行它。
First, we’ll create a simple test plan in the master system that contains the HTTP Request sampler to request our baeldung.com server, and a View Results Tree listener.
首先,我们将在主系统中创建一个简单的测试计划,其中包含HTTP Request采样器,以请求我们的baeldung.com服务器,以及View Results Tree监听器。
4.1. Starting a Single Slave
4.1.启动单个从机
Then, we can choose which slave system to run using GUI mode by using the Run > Remote Start option:
然后,我们可以通过使用Run > Remote Start选项,选择使用GUI模式运行哪个从属系统。
4.2. Starting All Slaves
4.2.启动所有从机
Similarly, we can choose to run all slave systems by using the Run > Remote Start All option:
同样,我们可以通过使用Run > Remote Start All选项来选择运行所有从属系统。
Additionally, a few options are available to handle test execution on the slave systems like Remote Stop, Remote Stop All, and Remote Shutdown All.
此外,有几个选项可用于处理从属系统上的测试执行,如远程停止、远程全部停止和远程全部关闭。
4.3. Test Results
4.3.测试结果
Finally, we can see the test results in the local JMeter (master) once test execution finishes:
最后,一旦测试执行结束,我们可以在本地JMeter(主站)看到测试结果。
Also, on the remote JMeter systems (slaves), we can find logs about the start/stop of the test execution:
另外,在远程JMeter系统(从机)上,我们可以找到关于测试执行的开始/停止的日志。
Starting the test on host 192.165.0.10 @ Sun Oct 25 17:50:21 EET 2020
Finished the test on host 192.165.0.10 @ Sun Oct 25 17:50:25 EET 2020
5. Conclusion
5.总结
In this quick tutorial, we’ve seen how to get started with distributed performance testing using JMeter.
在这个快速教程中,我们已经看到如何使用JMeter开始进行分布式性能测试。
First, we looked at a few prerequisites for a smooth setup and test run. Then, we configured our slaves and master systems for a distributed performance testing environment.
首先,我们看了一些先决条件,以便顺利设置和测试运行。然后,我们为分布式性能测试环境配置了我们的从属系统和主系统。
Last, we started the slave systems, ran tests from a master system, and observed the results.
最后,我们启动了从属系统,从主系统运行测试,并观察结果。