JMeter distributed testing in Non-gui mode

Source: Internet
Author: User

Since JMeter is a pure Java application, using GUI mode to run the stress test, the client resource consumption is quite amazing, so in the formal pressure measurement must use Non-gui mode, if the number of concurrency is high or the hardware resources of the client is more general, You can also use multiple clients for distributed testing in server mode. My friends have been asking me how to use this distributed test, I will combine the official documents with my own practical experience to talk about.

First, make sure that your environment is ready in your system, or there may be some exceptions thrown to cause script execution to fail when you perform some of the actions below

Front-facing work
    • Java_home correct settings (if not, please Google yourself)
    • JMeter and related plugins have been installed (for this step in doubt, please move to my other blog using JMeter to create ACTIVEMQ JMS Point-to-point requests, environment building, request creation, plug-in installation, listener server resources, etc.)
    • To configure Jmeter_home, step:
      • Linux & MacOS X
        • Vim ~/.profile
        • Add the following code at the end of the file:
          Export jmeter_home=/yourpath/apache-jmeter-x.y#Yourpath is your JMETER extract directory #  X.Y is the JMeter version, of course you can also rename this directory

        • Run the following command to make the configuration effective
          SOURCE ~/.profile

        • Enter jemeter-v at the command line if you print out JMeter version information stating that the environment is configured successfully
      • Windows
        • Computer-Properties-Advanced system settings-environment variables
        • Click New, variable name input: jmeter_home, variable value enter your JMETER decompression path
        • Click OK, then edit path to add%jmeter_home%\bin to the end of the variable value
        • After Setup, verify that the configuration is successful, open the DOS window input jemeter-v, if you print out the JMeter version information, the environment configuration is successful
Some information that you must know

Since is to run through the Non-gui mode, then we have to understand the next in the Non-gui mode jmeter command parameters, the following is the JMeter official documents listed in some of the parameters, the Chinese note part for me to join the explanation

-H,-- HelpPrintUsage information andExit#Printing Help Information-V,--versionPrintThe version information andExit#Print version Information-P,--propfile {Argument} The JMeter property file to use#The runtime specifies the property file, the default is to use the under the Jmeter_home/bin directory, if the user has other configurations, add            #usage is as follows:-P,--addprop {Argument} additional property file (s)#other configuration files, such as JVM parameters, etc.-T,--testfile {argument} the JMeter test (. jmx) file to run#the JMeter script to run-j,--jmeterlogfile {argument} The JMeter log file#specify the file that records JMeter log, default is Jmeter.log-L,--logfile {argument} The file to log samples to#record the file of the sampler log-N,--Nongui Run JMeterinchNongui Mode#run JMeter in Nongui mode-S,--Server Run the JMeter server#running JMeter Server-H,--proxyhost {argument} Set a proxy server forJMeter to use#Proxy server Address-P,--proxyport {argument} Set Proxy Server port forJMeter to use#Proxy Server Port-U,--username {argument} Set username forProxy server that JMeter is to use#the user name of the proxy server-A,--password {argument} Set password forProxy server that JMeter is to use#password for proxy server user name-j,--jmeterproperty {argument}={Value} Define additional JMeter properties#to define additional JMeter properties-G,--globalproperty (argument) [=(value)] Define Global Properties (sent to servers) global properties sent to server           #such as:-gport=123 (specifies the port of the listener server)-D,--systemproperty {argument}={Value} Define additional System properties#Defining System Properties-S,--systempropertyfile {filename} A property file to be added as System properties#define system Properties by the specified property file-L,--loglevel {argument}={value} Define loglevel: [Category=]level e.g. Jorphan=infoorJmeter.util=DEBUG#defining log Levels-R,--runremote (non-GUI only) Start remote servers (as defined by the JMeter property remote_hosts)#Start remote server (remote_hosts defined in JMeter property), this parameter is not valid in Non-gui mode-R,--remotestart Server1,... (non-GUI only) Start these remote servers (Overrides remote_hosts)#Start remote server (if you use this parameter, the remote_hosts defined in the JMeter property will be ignored)-D,--homedir {argument} The JMeter home directory to use#JMeter running the home directory-X,--remoteexit Exit The remote servers at end of test (non-GUI)#exit at end of test (in Non-gui mode)
View CodeConfiguring JMeter Client & Server

After understanding the above parameters, start configuring the distributed test

Let's take a look at what the official documents say, and add comments to me in Chinese:

1. The firewalls on the systems is turned off.#1. Turn off the firewall2. All the clients is on the same subnet.#2. All clients are within the same subnet3. The server is inchThe same subnet,if192.x.x.xor10. x.x.x IP addresses is used. If the SERVERDOESN't use 192 or IP address, there shouldn'T is any problems.#3.server must also be in the same subnet if you use an IP address such as 192.x.x.x or 10.x.x.x, if the server is not using an IP address such as 192 or 10, there will be no problem with the server in the same subnet as the client. 4. Make sure JMeter can access the server.#4. Ensure that JMeter can access the server5. Make sure to the same version of JMeter on all the systems. Mixing versions May notworkcorrectly.#5. Ensure that the JMeter versions of the systems are consistent and that different versions of JMeter will not work well

The idea of distributed testing is: a master host initializes the test and controls multiple slave systems for the server and client structure:

To jmeter the actual run-time structure:

Explanation of some terms:

    • Master, run in GUI mode while controlling the run of the test, here is the client, the machine where the script is started.
    • Slave, running Jmeter-server and receiving instructions from master, sending requests to the target server

Set Jmeter-server:

Open the file in the Jmeter_home/bin directory with a text editor and add the host IP that runs jmeter-server to Remote-hosts


If you do not want your client to run as Jmeter-server, remove localhost from the configuration above.

Write so much, below the actual combat stage:

  1. Start the jmeter-server on the machine that is configured in Remote_hosts (Windows runs as Administrator jmeter-server.bat,linux& in the Jmeter_home/bin directory MacOS Run under the Jmeter_home/bin directory jmeter-server)
    • One more word here, there is a configuration in the official documentation
      1. On the slave systems, go to Jmeter/bin directory and execute Jmeter-server.bat (Jmeter-server Onunix). On Windows, you should see a DOS window appear with "Jre\[version]\bin\rmiregistry.exe". If this doesn ' t happen, it means either the environment settings is not right, or there aremultiple JRE installed on the System. Note: [version] would is the JRE version installed on thesystem.1. Open Jmeter-server.bat in a text Editor2. Go to line and find ": Setcp" 3. Edit "START Rmiregistry" to the full path. Example: "Startc:\<java_home>\jre\bin\rmiregistry"

      In fact this step can be omitted (I use the version is 2.13), the number of lines in the document is not correct, it should be the previous version of the bar, of course, the configuration is no problem

  2. Start JMeter in GUI mode on the client, and then open or create a test script
  3. Start all remote servers from GUI mode, method: Run-remote all start, see, can also start a single jmeter-server
    • If a jmeter-server is not started or has a problem with the configuration, then this test will not run and will report the following error (I am not starting jmeter-server on the 140 machine):
    • After successful startup, you can see the following log output on the machine running Jmeter-server
  4. At this point, the script debugging is complete, turn off the JMeter GUI (first through the GUI to stop the remote already opened Jmeter-server)
  5. Enter the directory where the test script is located and execute the following command
    • Jmeter-t "JMS point-to-point.jmx"-n-l testresult.csv-r

      After successful operation, the following log output can be seen on the client machine:

So far, the JMeter distributed test has been run through Non-gui mode.

Here's a tip: running JMeter in a distributed way is to run the same test script on all servers, that is, if you're going to 1s up to 100 threads, if you're using 5 machines for distributed testing, debug the script to 20 threads from 1s, otherwise, the 1s has 500 threads, which may differ from your expectations.

In practice, it is found that by setting the JMeter, the number of concurrent clients is very good, and the latter is devoted to writing an article about JMeter tuning.

Welcome to read reproduced this article, such as the text described in question or have not understand the place, please leave a message or contact me: [Email protected]

JMeter distributed testing in Non-gui mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.