A 2000-word article from 0 to 1 will teach you jmeter distributed pressure measurement

1. Why does jmeter do distributed pressure measurement

Limitations of jmeter itself

  • The number of threads supported by Jmeter of a press is limited by Jmeter's own mechanism and hardware configuration (memory, CPU, etc.)
  • Since Jmeter is a Java application, it consumes a lot of CPU and memory . When it is necessary to simulate a large number of concurrent users, a single machine is prone to JAVA memory overflow errors , which leads to a bottleneck in the test script itself.

Limitations of JVM heap memory

The jvm heap memory heap of a Java application is limited by the press hardware, although we can adjust the heap memory size

When cmd enables Jmeter GUI, there will also be a prompt

increase Java Heap to meet your test requirements: Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file

Translation: Increase the Java heap memory to meet the requirements of the test

However, a single machine cannot support tens of thousands of concurrency. At this time, multiple presses are needed for distributed stress testing, so that the performance bottleneck will not be our presses.

Lenovo scene

  • Test the scenario of 1000 thread concurrency, but a single machine can only support 200 concurrency and cannot reach 1000
  • 1000 concurrency can be simulated through distributed (from 5 machines)

Distributed stress testing

Jmeter supports distributed pressure measurement, and distributes a large number of concurrent users that need to be simulated to multiple presses, so that Jmeter has a larger load and meets real business scenarios (high concurrency scenarios)

The ultimate goal of distribution

  • Ensure that the press does not experience performance bottlenecks
  • One of the main reasons why you don't need to consider whether the press will cause a performance bottleneck when performing performance analysis later

2. Distributed principle

After reading the animation above, you will understand. The principle is as follows:

  1. Cnotroller is the control machine, Slaves are multiple presses
  2. In distributed testing, Cnotroller distributes test scripts to all Slaves through the command line
  3. Slave does not need to start Jmeter GUI, and executes tests through CLI mode
  4. After the Slave finishes executing, it will send the result back to the Master
  5. Master collects the results of all Slaves and aggregates them into a result set

Notice

  • The press machine can also be called: load machine, agent machine, executive machine, broiler... various names, but they are all Slave
  • Master can also execute test scripts, or not execute only responsible for management

3. The prerequisites for distributed pressure testing have been configured

注意事项

1、保持Contorller和Slave机器的JDK、jmeter以及插件等配置版本一致;
2、如果测试数据有用到CSV或者其他方式进行参数化,需要将data在每台Slave上复制一份,且读取路径必须保持一致;
3、确保Contorller和Salve机器在同一个子网里面;
4、检查防火墙是否被关闭,端口是否被占用(防火墙会影响脚本执行和测试结构收集,端口占用会导致Slave机报错);
5、分布式测试中,通过远程启动代理服务器,默认查看结果树中的响应数据为空,只有错误信息会被报回;
6、如果并发较高,建议将Contorller机设置为只启动测试脚本和收集汇总测试结果,在配置文件里去掉Contorller机的IP;

1. Modify the Contorller configuration

Open the bin directory under the jmeter installation file under the Contorller machine: the jmeter.properties file, search for remote_hosts=127.0.0.1, and write the IP and port of the Slave machine behind, for example:

remote_hosts=127.0.0.1:1099,172.16.6.90:1099,172.16.6.91:1099

Among them, 172.16.6.90 and 172.16.6.90 are the IP of the Slave machine, and each Agent machine is separated by a comma in English, modify and save. Note that the default port is 1099

Remember to modify regardless of the master machine: server.rmi.ssl.disable=true , and remove #, otherwise an error will be reported

2. Load machine

  1. First install the jdk and jmeter environment, see my last article for details. Then open the configuration file /bin/jmeter.properties, find and cancel the comment server.rmi.ssl.disable=false of this configuration, and change false to true.
# Password of Trust store
#server.rmi.ssl.truststore.password=changeit
#
# Set this if you don't want to use SSL for RMI
server.rmi.ssl.disable=true      # 改成true
  1. Enter the command: jmeter-server -Djava.rmi.server.hostname=172.16.2.114 to start the anget node. The parameters behind jmeter-server specify the IP of the agent

3. Start jemter

After starting jmeter, set the thread group, configuration components, samplers, listeners and other components, and click "Run-Remote Start":

You can choose to start a Slave machine remotely, or choose to start all of them remotely, and then you can perform distributed testing

Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free【保证100%免费】

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/131536718