In JMeter, how do the -r and -R command-line flags differ?
answer
- Both are refused outside non-GUI mode
- One of the two takes no argument
- A JMeter property supplies the default list
- The uppercase form carries the hosts itself
basics
~10 sBoth start a JMeter run on remote server processes instead of locally. -r uses the host list already in the remote_hosts property; -R takes the list inline and overrides it.
solid answer
~40 sIn a non-GUI JMeter run, `-r` (`--runremote`) takes no argument and drives the hosts named by the `remote_hosts` JMeter property; the shipped `bin/jmeter.properties` at 6.0.0 sets that to `127.0.0.1`, and JMeter falls back to `127.0.0.1` in code if the property is missing. `-R` (`--remotestart`) carries its own comma-separated list, as in `jmeter -n -t plan.jmx -R gen1,gen2,gen3,gen4`, and that list wins for the run. Each entry may be `host` or `host:port`; a bare host is looked up on the port given by `server.rmi.port`, default `1099`. Both flags demand `-n` and `-t`: JMeter refuses a GUI launch with `-r and -R and -X are only valid in non-GUI mode`, and a non-GUI launch with no plan with `Non-GUI runs require a test plan`.
code
bash · 11 lines# on each generator, first
jmeter-server
# on the laptop: hosts come from remote_hosts in bin/jmeter.properties
jmeter -n -t plan.jmx -l run.jtl -r
# on the laptop: hosts given inline, overriding remote_hosts
jmeter -n -t plan.jmx -l run.jtl -R gen1,gen2,gen3,gen4
# gen4 was started with SERVER_PORT=1234
jmeter -n -t plan.jmx -l run.jtl -R gen1,gen2,gen3,gen4:1234go deeper
Recall that -r and -R both belong to a non-GUI JMeter run, that -R carries the hosts itself, and that both need -n and -t on the same command line.
Explain where the host list comes from when only -r is given, that the shipped remote_hosts is 127.0.0.1, and that a bare entry is looked up on port 1099 unless you write host:port.
Show that you check the controller's console for the per-host 'Configuring remote engine' lines before blaming the network, and that you know the flags neither start nor stop the server processes.
Decide whether the host list belongs in a checked-in properties file or on the command line, so that the same plan can be pointed at different generator sets without editing anything under version control.
## The two flags in one line `-r` and `-R` both switch a JMeter CLI run from *drive the plan here* to *drive it on engines this process does not host*. They differ only in where the host list comes from. | Flag | Long form | Argument | Host list source | |---|---|---|---| | `-r` | `--runremote` | none | the `remote_hosts` JMeter property | | `-R` | `--remotestart` | required | the comma-separated list you type after it | `-R` is not "`-r` plus a list". It is a separate option and it is sufficient on its own: JMeter looks for `-R` first and only falls back to `-r` when `-R` is absent. Passing both is harmless, and `-R` wins. ## Where the list really comes from At Apache JMeter 6.0.0 the shipped `bin/jmeter.properties` carries this line **uncommented**: ```properties remote_hosts=127.0.0.1 ``` So a bare `-r` on an untouched installation targets the loopback address rather than failing with an obvious "you configured nothing" message. If you delete the property outright, JMeter still falls back to `127.0.0.1` in code, so the behaviour is the same either way. Each entry in either list is trimmed and may be written two ways: - a bare `host`, which is looked up on the port named by the `server.rmi.port` property, default `1099`; - `host:1234`, which overrides that for this entry alone — the form you need when a generator was started with a non-default `SERVER_PORT`; - an IPv6 literal in brackets works too, because JMeter looks for the port separator only after the closing `]`. ## Four engines from one laptop With `jmeter-server` already running on `gen1` through `gen4`, the laptop is the controller: ```bash # host list taken from remote_hosts in bin/jmeter.properties jmeter -n -t plan.jmx -l run.jtl -r # host list given inline, overriding remote_hosts for this run only jmeter -n -t plan.jmx -l run.jtl -R gen1,gen2,gen3,gen4 # one generator was started with SERVER_PORT=1234 jmeter -n -t plan.jmx -l run.jtl -R gen1,gen2,gen3,gen4:1234 ``` The controller prints `Configuring remote engine: gen1` for each host, then `Starting distributed test with remote engines: [gen1, gen2, gen3, gen4]`, and the process stays alive until every engine has reported that its test ended. ## Both flags are non-GUI only JMeter checks the combination before it does anything else. If `-n` is missing and any of `-r`, `-R` or `-X` is present, it refuses to start and prints: ```text Error: -r and -R and -X are only valid in non-GUI mode ``` `-t` is equally mandatory — a non-GUI run with no plan fails with `Non-GUI runs require a test plan`. Inside the GUI the equivalent controls are the **Run > Remote Start** and **Remote Start All** menu items, which read the same `remote_hosts` property; the flags are simply not wired into that path. ## What these flags do not do 1. **They do not copy the plan.** Nothing is written to the generators. The controller parses `plan.jmx` locally, clones the resulting tree and sends it over RMI, so the `.jmx` file never has to exist on `gen1`–`gen4`. 2. **They do not start the server processes.** `bin/jmeter-server` must already be running on each host; if it is not, the controller fails to find a bound engine there. 3. **They do not assign `remote_hosts`.** The JMeter manual describes `-R list` as equivalent to `-r` plus `-Jremote_hosts=list`, but at 6.0.0 the code hands the `-R` argument straight to the distributed runner and never writes it into the property. Anything on the controller that reads `remote_hosts` as a property still sees the value from the file. 4. **They do not shut the servers down.** Once the run ends the engines are still resident and ready for the next controller, unless you also pass `-X`.
- The JMeter manual calls -R equivalent to -r plus -Jremote_hosts=<list>. Where does that equivalence break down?For the run itself it holds, but at 6.0.0 JMeter never assigns the list to the property: the -R argument is passed straight to the distributed runner, and `remote_hosts` is only ever read, never written. So anything on the controller that consults `remote_hosts` as a property still sees the value from jmeter.properties.
- What happens if you run jmeter -n -t plan.jmx -r on a machine where no JMeter server process is running?The controller targets 127.0.0.1, the value the shipped remote_hosts carries, finds no engine bound there, and with client.continue_on_fail at its default of false it stops and throws `Following remote engines could not be configured:[127.0.0.1]`. It is the commonest first-run surprise, and it looks like a network fault rather than a configuration gap.
saying these in an interview costs you the question
- Thinks -R works from the JMeter GUI without -n.
- Believes -r copies the .jmx file out to each server first.
- Says -R has to be combined with -r; -R alone already starts the remote run.
- Assumes remote_hosts entries must be bare hostnames, so host:port is rejected.
- Expects -r to accept a host list as its argument.