|
JMeter example source code file (remote-test.xml)
The JMeter remote-test.xml source code<?xml version="1.0"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!DOCTYPE document[ <!ENTITY sect-num '15'> ]> <document prev="listeners.html" next="best-practices.html" date="$Date: 2010-05-20 17:38:51 +0100 (Thu, 20 May 2010) $"> <properties> <title>User's Manual: Remote (Distributed) Testing </properties> <body> <section name="§-num;. Remote Testing"> <p>In the event that your JMeter client machine is unable, performance-wise, to simulate enough users to stress your server, an option exists to control multiple, remote JMeter engines from a single JMeter GUI client. By running JMeter remotely, you can replicate a test across many low-end computers and thus simulate a larger load on the server. One instance of the JMeter GUI client can control any number of remote JMeter instances, and collect all the data from them. This offers the following features: <ul> <li>Saving of test samples to the local machine <li>Managment of multiple JMeterEngines from a single machine <li>No need to copy the test plan to each server - the client sends it to all the servers </ul> </p> <note> Note: The same test plan is run by all the servers. JMeter does not distribute the load between servers, each runs the full test plan. </note> <p> However, remote mode does use more resources than running the same number of non-GUI tests independently. If many server instances are used, the client JMeter can become overloaded, as can the client network connection. </p> <p>Note that while you can execute the JMeterEngine on your application server, you need to be mindful of the fact that this will be adding processing overhead on the application server and thus your testing results will be somewhat tainted. The recommended approach is to have one or more machines on the same Ethernet segment as your application server that you configure to run the JMeter Engine. This will minimize the impact of the network on the test results without impacting the performance of the application serer itself. </p> <p>Step 0: Configure the nodes <p> Make sure that all the nodes (client and servers) are running exactly the same version of JMeter. As far as possible, also use the same version of Java on all systems. Using different versions of Java may work - but is best avoided. </p> <p> If the test uses any data files, note that these are not sent across by the client so make sure that these are available in the appropriate directory on each server. If necessary you can define different values for properties by editting the user.properties or system.properties files on each server. These properties will be picked up when the server is started and may be used in the test plan to affect its behaviour (e.g. connecting to a different remote server). Alternatively use different content in any datafiles used by the test (e.g. if each server must use unique ids, divide these between the data files) </p> <p>Step 1: Start the servers <p>To run JMeter in remote node, start the JMeter server component on all machines you wish to run on by running the JMETER_HOME/bin/jmeter-server (unix) or JMETER_HOME/bin/jmeter-server.bat (windows) script. <p>Note that there can only be one JMeter server on each node unless different RMI ports are used. <p>Since JMeter 2.3.1, the JMeter server application starts the RMI registry itself; there is no need to start RMI registry separately. To revert to the previous behaviour, define the JMeter property server.rmi.create=false on the server host systems. </p> <p> By default, RMI uses a dynamic port for the JMeter server engine. This can cause problems for firewalls, so versions of JMeter after 2.3.2 will check for the JMeter property <b>server.rmi.localport. If this is non-zero, it will be used as the local port number for the server engine. </p> <p>Step 2: Add the server IP to your client's Properties File <p>Edit the properties file on the controlling JMeter machine. In /bin/jmeter.properties, find the property named, "remote_hosts", and add the value of your running JMeter server's IP address. Multiple such servers can be added, comma-delimited.</p> <p>Note that you can use the -R command line option instead to specify the remote host(s) to use. This has the same effect as using -r and -Jremote_hosts={serverlist}. E.g. jmeter -Rhost1,127.0.0.1,host2</p> <p>If you define the JMeter property server.exitaftertest=true, then the server will exit after it runs a single test. See also the -X flag (described below) </p> <p>Step 3a: Start the JMeter Client from a GUI client <p>Now you are ready to start the controlling JMeter client. For MS-Windows, start the client with the script "bin/jmeter.bat". For UNIX, use the script "bin/jmeter". You will notice that the Run menu contains two new sub-menus: "Remote Start" and "Remote Stop" (see figure 1). These menus contain the client that you set in the properties file. Use the remote start and stop instead of the normal JMeter start and stop menu items.</p> <figure image="remote/run-menu00.gif" width="232" height="156">Figure 1 - Run Menu <p>Step 3b: Start the JMeter from a non-GUI Client <p> As an alternative, you can start the remote server(s) from a non-GUI (command-line) client. The command to do this is: <pre> jmeter -n -t script.jmx -r or jmeter -n -t script.jmx -R server1,server2... Other flags that may be useful: -Gproperty=value - define a property in all the servers (may appear more than once) -Z - Exit remote servers at the end of the test. </pre> The first example will start whatever servers are defined in the JMeter property remote_hosts; the second example will define remote_hosts from the list of servers and then run the remote servers. <br/> The command-line client will exit when all the remote servers have stopped. </p> <subsection name="§-num;.1 Doing it Manually" anchor="detail_instructions"> <p>In some cases, the jmeter-server script may not work for you (if you are using an OS platform not anticipated by the JMeter developers). Here is how to start the JMeter servers (step 1 above) with a more manual process: <p>Step 1a: Start the RMI Registry <p> Since JMeter 2.3.1, the RMI registry is started by the JMeter server, so this section does not apply in the normal case. To revert to the previous behaviour, define the JMeter property server.rmi.create=false on the server host systems and follow the instructions below. </p> <p>JMeter uses Remote Method Invocation (RMI) as the remote communication mechanism. Therefore, you need to run the RMI Registry application (which is named, "rmiregistry") that comes with the JDK and is located in the "bin" directory. Before running rmiregistry, make sure that the following jars are in your system claspath: <ul> <li>JMETER_HOME/lib/ext/ApacheJMeter_core.jar <li>JMETER_HOME/lib/jorphan.jar <li>JMETER_HOME/lib/logkit-1.2.jar </ul> The rmiregistry application needs access to certain JMeter classes. Run rmiregistry with no parameters. By default the application listens to port 1099.</p> <p>Step 1b: Start the JMeter Server <p>Once the RMI Registry application is running, start the JMeter Server. Use the "-s" option with the jmeter startup script ("jmeter -s").</p> <p>Steps 2 and 3 remain the same. </subsection> <subsection name="§-num;.2 Tips" anchor="tips"> <p> JMeter/RMI requires a connection from the client to the server. This will use the port you chose, default 1099. JMeter/RMI also requires a reverse connection in order to return sample results from the server to the client. This will use a high-numbered port. If there are any firewalls or other network filters between JMeter client and server, you will need to make sure that they are set up to allow the connections through. If necessary, use monitoring software to show what traffic is being generated. </p> <p>If you're running Suse Linux, these tips may help. The default installation may enable the firewall. In that case, remote testing will not work properly. The following tips were contributed by Sergey Ten. <p>If you see connections refused, turn on debugging by passing the following options. rmiregistry -J-Dsun.rmi.log.debug=true -J-Dsun.rmi.server.exceptionTrace=true -J-Dsun.rmi.loader.logLevel=verbose -J-Dsun.rmi.dgc.logLevel=verbose -J-Dsun.rmi.transport.logLevel=verbose -J-Dsun.rmi.transport.tcp.logLevel=verbose <p>Since JMeter 2.3.1, the RMI registry is started by the server; however the options can still be passed in from the JMeter command line. For example: "jmeter -s -Dsun.rmi.loader.logLevel=verbose" (i.e. omit the -J prefixes). Alternatively the properties can be defined in the system.properties file. </p> <p>The solution to the problem is to remove the loopbacks 127.0.0.1 and 127.0.0.2 from etc/hosts. What happens is jmeter-server can't connect to rmiregistry if 127.0.0.2 loopback is not available. Use the following settings to fix the problem. <p> Replace <ul> <li> `dirname $0`/jmeter -s "$@" </ul> <p> With <ul> <li> HOST="-Djava.rmi.server.hostname=[computer_name][computer_domain] <li> -Djava.security.policy=`dirname $0`/[policy_file]" <li> `dirname $0`/jmeter $HOST -s "$@" </ul> <p>Also create a policy file and add [computer_name][computer_domain] line to /etc/hosts. </subsection> <subsection name="§-num;.3 Using a different port" anchor="portchange"> <p>By default, JMeter uses the standard RMI port 1099. It is possible to change this. For this to work successfully, all the following need to agree: <ul> <li>On the server, start rmiregistry using the new port number <li>On the server, start JMeter with the property server_port defined <li>On the client, update the remote_hosts property to include the new remote host:port settings </ul> <p>Since Jmeter 2.1.1, the jmeter-server scripts provide support for changing the port. For example, assume you want to use port 1664 (perhaps 1099 is already used).</p> <pre> On Windows (in a DOS box) C:\JMETER> SET SERVER_PORT=1664 C:\JMETER> JMETER-SERVER [other options] On Unix: $ SERVER_PORT=1664 jmeter-server [other options] [N.B. use upper case for the environment variable] </pre> <p> In both cases, the script starts rmiregistry on the specified port, and then starts JMeter in server mode, having defined the "server_port" property. </p> <p> The chosen port will be logged in the server jmeter.log file (rmiregistry does not create a log file). </p> </subsection> <subsection name="§-num;.4 Using sample batching" anchor="batchmode"> <p> Listeners in the test plan send their results back to the client JMeter which writes the results to the specified files By default, samples are sent back as they are generated. This can place a large load on the network and the JMeter client. There are some JMeter properties that can be set to alter this behaviour. </p> <ul> <li>mode - sample sending mode - default is Standard <ul> <li>Standard - send samples as soon as they are generated <li>Hold - hold samples in an array until the end of a run. This may use a lot of memory on the server. <li>Batch - send saved samples when either the count or time exceeds a threshold <li>Statistical - send a summary sample when either the count or time exceeds a threshold. The samples are summarised by thread group name and sample label. The following fields are accumulated: <ul> <li>elapsed time <li>latency <li>bytes <li>sample count <li>error count </ul> Other fields that vary between samples are lost. </li> <li>Stripped - remove responseData from succesful samples <li>StrippedBatch - remove responseData from succesful samples, and send as batches <li>Custom implementation : set the mode parameter to your custom sample sender class name. This must implement the interface SampleSender and have a constructor which takes a single parameter of type RemoteSampleListener. </li> </ul> </ul> <p>The following properties apply to the Batch and Statistical modes: <ul> <li>num_sample_threshold - number of samples in a batch (default 100) <li>time_threshold - number of milliseconds to wait (default 60 seconds) </ul> </subsection> </section> </body> </document> Other JMeter examples (source code examples)Here is a short list of links related to this JMeter remote-test.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.