How does JMeter perform multi-server remote testing

JMeter is an open source project of the Apache Software Foundation, mainly for functional and performance testing, written in Java.

We generally use JMeter to test locally, but affected by the performance of a single computer, it often fails to meet the requirements of performance testing and cannot effectively simulate high-concurrency scenarios. At this time, we can use the Romote Test provided by JMeter for remote testing.

Its working method is shown in the figure below:


We can start JMeter's Romote Testing mode on multiple computers, and then use a certain server as the Master to control the Slave through RMI to execute our test scripts. When the JMeter Slave end executes the test script, it will send the execution results back to the Master control end for summary, and obtain the overall test report.

The advantage of JMeter's Romote Test mode is that you can use one terminal and one test plan to test the target server on multiple servers at the same time, and report the test results to a unified control terminal for summary, which is convenient for high-concurrency testing requirements.

The following describes how to use JMeter for remote testing.

Step 1: Install JMeter on the Slave side
  
JMeter can be downloaded from the official website, download address: https://jmeter.apache.org/download_jmeter.cgi
  
Since the operation of JMeter requires a Java environment, Java must also be installed on the server side.
  
Note: In order for the Remote Testing mode to work normally, try to ensure that the JMeter and Java versions of the Slave and Master are consistent.
  
Step 2: Run JMeter on the Slave side
  
In the bin directory of JMeter, execute the following command to start the Slave side of JMeter as a service:

jmeter-server

On the JMeter Slave side, the RMI (Remote Method Invoke) mechanism will be started by default. The default port of RMI is 1029, which can be modified in the file jmeter.properties.
  
In addition, starting from JMeter 4.0, RMI will use SSL connection by default. In order to allow the Slave and Master to communicate normally, we need to generate corresponding keys and certificates. In the bin directory of JMeter, it comes with a JKS (Java KeyStore) file generation command.
 
  
Run the following command in the bin directory of JMeter, and enter the corresponding content according to the prompt:

>bin % ./create-rmi-keystore.sh 
  What is your first and last name?
    [Unknown]:  rmi
  What is the name of your organizational unit?
    [Unknown]:  unit
  What is the name of your organization?
    [Unknown]:  org
  What is the name of your City or Locality?
    [Unknown]:  city
  What is the name of your State or Province?
    [Unknown]:  prov
  What is the two-letter country code for this unit?
    [Unknown]:  cn
  Is CN=rmi, OU=unit, O=org, L=city, ST=prov, C=cn correct?
    [no]:  yes
  Enter key password for <rmi>
      (RETURN if same as keystore password):  
  Re-enter new password: 
  Copy the generated rmi_keystore.jks to jmeter/bin folder or reference it in property 'server.rmi.ssl.keystore.file'

Note: The content in the prompt, the first name and the last password need to be recorded, and other content can be filled in at will.
  
For example, the first name I filled in here is rmi, and the last password is set to changeit. If you fill in other values ​​here, then you need to write your values ​​into the jmeter.properties file, corresponding to two Attributes:

 server.rmi.ssl.keystore.alias
  server.rmi.ssl.truststore.password

Finally, we also need to follow the prompts to copy the generated rmi_keystore.jks file to the bin directory of JMeter that needs to be connected. If it is placed in another directory, we need to specify the directory of the .jks file through server.rmi.ssl.keystore.file in the jmeter.properties file.

Step 3: Master controls Slave to execute test scripts

After the Slave end is successfully started, we can try to perform connection control on the Master end.
  
First, we need to add the IP:Port of the remote JMeter server (Slave side) to the local JMeter by modifying the jmeter.properties file in the local bin directory, find remote_hosts in it, and add the host and port of our remote JMeter Here, if there are more than one, use , to separate.

remote_hosts=<server ip>:1199

Once configured, we can run the command to execute our test plan:

./jmeter.sh -n -t test.jmx -r

-r: will control all Slave terminals configured in remote_hosts to execute our test plan test.jmx;
  
you can also specify the specific IP:Port of the remote JMeter you want to control directly on the command line, the command is as follows:

./jmeter.sh -n -t test.jmx -R<IP>:1099

Problems and Solutions
 
There may be many problems here, here are some of the pits I have stepped on:

  1. Master reports that the connection is rejected. At this time, you need to check the firewall settings to see if the port is blocked;
  2. When the Slave side starts, you will find that the port is random each time, which may cause the port policy of the firewall to be modified every time. We can set a fixed port by modifying server.rmi.localport in jmeter.properties The port number;
  3. In some special cases, there will also be problems that the client cannot connect. For example, some servers have dual network cards. At this time, we may need to specify the IP of the server that JMeter starts. The configuration method is to modify bin/jmeter-server file, modify the commented line as follows:
RMI_HOST_DEF=-Djava.rmi.server.hostname=1.2.3.4

1.2.3.4 here is the IP of the network card you want to specify.

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.

insert image description here

Guess you like

Origin blog.csdn.net/m0_53918927/article/details/131419789