JMeter Installation and Load Testing Guide

JMeter Overview

JMeter is an open-source压力测试工具 developed by the Apache Software Foundation. It is built entirely in Java and serves as a comprehensive solution for性能测试 scenarios.

JMeter capabilities include:

  • Static resource testing (files served to clients)
  • Dynamic resource testing (content varying by user request)
  • Server and network testing

Installation and Startup

Prerequisites

Ensure Java is installed before proceeding. Java can be downloaded from Oracle's official website if needed.

Download

Obtain JMeter from the official Apache website. After downloading, extract the archive to your preferred location.

Launch

Navigate to the JMeter binary directory and execute the startup script:

cd /path/to/apache-jmeter-5.x/bin
./jmeter.sh

The GUI interface will launch upon execution.


Core Concepts

Thread Group: A thread group represents a collection of virtual users. Each virtual user is implemented as a Java thread. Thread groups allow configuration of concurrent user simulation for load testing scenarios.


HTTP Load Testing with GUI Mode

This example demonstrates压力测试 against a web application.

Thread Group Configuration

Create a new thread group and configure the following parameters:

Parameter Value Description
Thread Count 100 Number of virtual users in the group
Ramp-Up Period 1 second Time for all users to start requesting
Loop Count 1 Number of times each virtual user executes the test

With these settings, 100 virtual users begin making requests within a 1-second window. Each user executes the test once and then exits.

Adding HTTP Request Sampler

Configure the HTTP request sampler with the target server hostname and request path.

Adding Listeners

Attach listeners to capture and analyze results:

  • View Results Tree
  • Aggregate Report
  • View Results in Table
  • Summary Report

Aggregate Report Metrics

The aggregate report provides the following key metrics:

Metric Definition
Average Mean response time across all requests
Median 50th percentile response time
90% Line 90th percentile response time
Min Minimum response time recorded
Max Maximum response time recorded
Error % Percentage of failed requests
Throughput Maximum data processing rate
Received Data reception rate
Sent Data transmission rate

Command Line Mode

Command line execution is recommended for large-scale tests as it reduces resource consumption.

Execution

Run the test configuration file and save results to a log file:

jmeter.sh -n -t test_plan.jmx -l results.jtl

The resulting JTL file can be imported into the GUI for visual analysis.


Distributed Load Testing

Motivation

Single-machine testing has hardware limitations. When concurrent users exceed thousands, a single machine's CPU and memory become bottlenecks. Distributed testing addresses this by coordinating multiple agent machines to share the load.

Architecture

  1. Master Node: Controls test execution and collects results from agents
  2. Agent Nodes: Execute the test script locally without GUI overhead
  3. Communication: Master distributes JMX files to agents, agents return result data after execution

Setup Steps

Step 1: Preparation

Install JMeter on both master and all agent machines. Ensure firewalls are disabled on all nodes and machines can communicate over the network.

Step 2: Configuration

On Master Node:

Edit bin/jmeter.properties and update the remote_hosts field with agent IP addresses:

remote_hosts=172.24.181.253

On Agent Nodes:

Modify bin/jmeter-server and configure the RMI_HOST_DEF field with the agent's own IP address.

Step 3: Launch via GUI

  1. Start agent servers first:
./jmeter-server
  1. Launch JMeter on master node after agents are runing

Step 4: Launch via Command Line

Target specific agents:

jmeter.sh -n -t test_plan.jmx -R 172.24.181.253 -l output.jtl

Target all configured agents:

jmeter.sh -n -t test_plan.jmx -r -l output.jtl

Important Notes

  • Disable firewalls on both master and agent nodes
  • Ensure all JMeter versions are consistent across nodes
  • JMX files do not need manual distribution—the master handles script transmission
  • Thread counts in JMX files apply per agent. If configured for 100 threads, each agent runs 100 threads, not 100 divided among all agents
  • Recommended thread count per agent: 100-300, depending on hardware specifications (CPU 1.4G-3GHz, 1GB RAM)

Multiple Agent Instances on Single Machine

For higher throughput, run multiple agent instances on one machine using different ports.

Configuration

On Agent:

Copy jmeter-server to jmeter-server2 and modify the port:

./jmeter ${RMI_HOST_DEF} -Dserver_port=${SERVER_PORT:-1199} -s -j agent2.log "$@"

Start both instances:

./jmeter-server    # port 1099
./jmeter-server2   # port 1199

On Master:

Update remote_hosts:

remote_hosts=10.99.197.118:1099,10.99.197.118:1199

Execution

jmeter.sh -n -t test_plan.jmx -R 10.99.197.118:1199,10.99.197.118:1099 -l results.jtl

Omitting port specifications causes JMeter to default to port 1099 only.


Open Questions

  • Dynamic path parameterization in thread groups
  • Agent daemon startup timing and task distribution mechanisms
  • Master-agent communication protocols
  • Network segment requirements for distributed deployments

Tags: jmeter load-testing performance-testing distributed-testing apache

Posted on Fri, 08 May 2026 17:29:07 +0000 by CodeToad