Demining Jmeter distributed performance testing, why use distributed? These error-prone points are particularly dangerous!

When doing back-end server performance testing, we often hear about distribution. Do you know about distribution?

Today, we will tell you how to use distributed performance testing in actual enterprise operations. What should we pay special attention to during actual operations?

01. Why use distributed

When doing performance testing, if the performance of the system under test is relatively good, or the system project is relatively large, it is generally required to support a relatively high number of concurrent users. When we do performance testing, the hardware resources of the machine that initiates the request are certain, and it is impossible to configure unlimited resources.

Therefore, the number of concurrent users it can initiate is limited. When the number of concurrent users that one of our initiator computers can initiate is less than the number of concurrent users expected by our performance test, we will naturally think of adding more initiator computers. Increase the number of initiating computers, then the cumulative number of concurrent users initiated will increase.

Generally speaking, a computer on the initiator, whether it is a Windows system or a Linux system, can support about 1.5k concurrent users. For more concurrent users, distribution will be required.

So, the next question is how to configure distribution?

02. How to configure distribution

To assist the machine configuration, modify the jmeter.properties file

  • First, we prepare multiple machines as assist machines;

  • Then, check whether JDK is installed on each machine and whether the JDK versions are consistent;

  • Then, place the same version of jmeter on the assist machine;

  • Next, configure the jmeter.properties file,

  • Modify the server_port port and customize a port

  • Modify server.rmi.ssl.disable=true

  • Modify server.rmi.port port ---- optional

  • Start the service:jmeter-server -Djava.rmi.server.hostname=ip_address

  • Check the firewall, close or open the custom server_port port

Main control machine configuration, modify the jmeter.properties file

  • Modify remote_hosts, the value is the assist machine ip

  • Modify, server.rmi.ssl.disable=true

  • Modify, mode=Standard

03. What are the precautions for distributed machine configuration?

Distributed configuration, isn’t it very simple?

Yes, this configuration is actually not difficult at all. If you want to practice it yourself, you can configure it easily and successfully by following the above operations. But is it still that simple when you're working on an enterprise project? If your company's project needs to support tens of thousands of concurrencies and uses dozens of assist machines, can you simply repeat the above operations?

the answer is negative

There are now dozens of Linux machines placed in front of you for you to configure as assist machines. The quantity is relatively large, and there is no guarantee that each one will be exactly the same. Therefore, we first need to check the machine configuration.

1. Hardware resources

CPU and memory are the core of a computer. There are dozens of machines. We cannot guarantee that each one is the same. Although there are no requirements for CPU and memory in the requirements of the assist machine, if each machine can provide If the resources are different, the number of concurrent users that can be generated will definitely be unequal.

Therefore, we need to find the machine with the lowest configuration among the machines, and then configure the jmeter stack information using the machine with the lowest configuration as a reference .

  • Use  top commands to view the CPU and memory information of each system

  •  Modify the size of jmeter the file  in the bin folder of jmeter  and modify the stack information.HEAP:="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m"

  • Without configuration, jmeter may cause OOM problems when executing with a high number of concurrent users.

2. System environment

JDK

If there are too many machines, it may be a problem whether the JDK version of each machine is consistent. If it is not installed on the machine, you can directly install the specified version. However, if other versions of JDK are already installed on the assist machine and other Java projects are running, what should you do at this time?

Specify the running JDK version of jmeter

  • Download and unzip the specified JDK version to the Linux  /usr/local folder. Do not configure or change the system environment variables.

  • In the jmeter file of jmeter, add  JAVA_HOME=/usr/local/jdk版本/ the JDK version that specifies the running jmeter. In this way, there is no need to modify the JDK of the operating system and it does not affect other Java projects in the system.

jmeter

jmeter version

  • The version of jmeter on all assist machines must be consistent .
  • jmeter.properties To modify  ssl.disable=true , the ports can be different
  • If third-party plug-ins are used in the code , these plug-in packages must also be available on the assist machine.
  • environment variables

    • When running jmeter, you do not need to configure the JMETER_HOME environment variable. However, when there are many machines, it is recommended to configure the JMETER_HOME environment variable on all machines.
  • HEAP configuration

  • There are many machines, and the memory of each machine may be different. We expect that the assist machine can generate a larger number of concurrent users. Therefore, it is recommended to modify the HEAP configuration information of each machine and set it to the same
  • CSV file

  • If the CSV data file setting is used in the jmeter script written, then the file path must be written using a relative path.
  • In whichever path the jmeter-server  assist service is started, you must upload the CSV file to the relative location in that path on all machines.

os operating system

  • os version: no requirement, can be different versions

  • Port range:

  • The number of ports in the operating system is limited. Different systems may have different numbers of ports opened by default . This requires us to configure the port range opened on each machine.

  • sysctl -a | grep net.ipv4.ip_local_port_range

This command can view the open port range on the current machine.

  • sysctl -w net.ipv4.ip_local_port_range="1024 65534" and then execute sysctl -p to take effect. In this way, set the open port range on each machine

  • sysctl -a | grep net.ipv4.ip_local_port_range

This command can view the open port range on the current machine.

Number of open files

  • The operating system has a limit on the number of files that each program can open. This is a system limit . We can  ulimit -n see it by  cat /proc/进程id/limit checking the limit on the number of files that a certain process can open today.

  • Because the performance test assists the machine, it also needs to initiate a large number of requests, which may open a large number of files. If the number of files is too small, it will also cause problems. Therefore, we can modify the number of files that the process can open  ulimit -n 数量 . Then, restart the jmeter-server assist service, so that the limit will be based on the number you modified.

  • time

  • There are many assist machines, and the time of each machine may be different. We can  date check the time of each machine.

  • For performance testing, the expectation is that a large number of requests can be initiated at the same time. If the times of multiple machines are inconsistent, the number of requests initiated at the same time may not meet the expected requirements. Therefore, we need to set the time of each machine synchronously . . date -s 时间 to set the system time.

Web environment

  • Dozens of machines may have different network configurations. If there are problems with the network between these assisting machines and the server under test, it may cause a decrease in request pressure or even a network error.

  • We can use on each assist machine to  tracepath 被测服务器 view the network conditions between the assist machine and the server under test . If you find that the network delay time is very long, it means that there may be a problem with the network configuration of the current machine. When using it, you may have to eliminate this assist machine.

Start service

  • Execute on each assist machine: jmeter-server -Djava.rmi.server.hostname=ipaddr Because the IP address of each machine is different, this command must be typed one by one. At the same time, we can add a '&' symbol to convert the command to run in the background.

  • Execute on the master machine:java -Xms48g -Xmx48g -XX:MaxMetaspaceSize=2g -jar $JMETER_HOME/bin/ApacheJMeter.jar -n -R xxx:port,xxx:port -t xxx.jmx -l xxxx.jtl -e -o xxdirect

  • -Xms48g -Xmx48g -XX:MaxMetaspaceSize=2g This is to set the stack information of the main control machine jmeter. This size can be flexibly modified according to the memory size of your own machine. However, this must be set relatively large . If it is smaller, it will take a long time to generate the report.

  • $JMETER_HOME/bin/ApacheJMeter.jar For your own jmeter path

  • -R xxx:port,xxx:port Designated assist machine. You can specify it according to your own needs. If you don't need to use distributed, you don't need this paragraph. If you want to use distributed, you need to use this paragraph. If there are multiple units, separate them with commas .

  • -t xxx.jmx The jmeter script file you put on the main control machine

Okay, have you learned all these precautions?

Finally: The complete software testing video tutorial below has been compiled and uploaded. Friends who need it can get it by themselves [guaranteed 100% free]

Software Testing Interview Document

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 Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.

Guess you like

Origin blog.csdn.net/weixin_50829653/article/details/133350191