Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 37 ยท Projects and Practice

Practice: Troubleshooting JMeter Test Plans

Practice diagnosing broken JMeter tests: unresolved variables, failed correlation, wrong thread counts, memory errors, RMI problems and misleading results, with exercises.

Every JMeter user spends time asking "why does this test not do what I expect?" The good news is that problems repeat. This final lesson gives you a method, a catalogue of symptoms with their usual causes, and exercises to practise on. JMeter cannot run on this site, so the exercises are paper-and-code puzzles: you read plan descriptions, logs and result excerpts, and use a Python stand-in to check your reasoning.

A method that works

  1. Reproduce with one thread, one iteration. Many problems vanish or become obvious when concurrency is removed.
  2. Look at the request and the response in View Results Tree (request tab, response data, headers). Compare with what a browser or curl sends.
  3. Read the logs. jmeter.log holds errors and warnings with stack traces; on agents also jmeter-server.log. Increase the log level for one category with -Ljmeter.protocol.http=DEBUG.
  4. Change one thing at a time and retest.
  5. Check the load generator (CPU, heap, network) before blaming the application.
  6. Only then look at the application and the environment.

A tip: the Debug Sampler (shows all variables and properties as a response) and the Debug PostProcessor are excellent for seeing what values exist at a point in the flow.

Symptom catalogue

Symptom Usual cause Fix
A request contains the literal text ${var} variable not defined yet, wrong name or scope, element order check name case; place the extractor before use; use Debug Sampler
All requests after login return 401 or 403 token or cookie not captured or not sent HTTP Cookie Manager, extractor, header manager placed correctly
Everything is fast and error rate is 100 percent requests rejected immediately (bad URL, TLS, auth) read the response body, check assertions and the target host
java.net.ConnectException: Connection refused wrong host or port, server down, firewall verify with curl, check the host variable and proxy settings
javax.net.ssl.SSLHandshakeException certificate not trusted, protocol mismatch import the certificate into the Java trust store; check TLS versions
java.lang.OutOfMemoryError: Java heap space heap too small, too many listeners, large responses stored raise -Xmx, remove listeners, stop saving bodies
Address already in use: connect out of ephemeral ports enable keep-alive, widen the port range, add agents
Throughput lower than the plan too few threads, long think times, timer misconfigured, generator saturated Little's Law, check CPU, check the Constant Throughput Timer scope
Test ends immediately Thread Group loop count 1, scheduler duration unset, error action "Stop Test" inspect the Thread Group settings
Cookie or session shared across users cookie manager set to share (CookieManager.save.cookies) or one Cookie Manager under a different scope check cookie scope and the "clear each iteration" option
Distributed run: Connection refused to host: 127.0.0.1 agent advertises loopback set java.rmi.server.hostname
Distributed run: nothing happens on an agent missing CSV or plugin on the agent compare the agents' file trees
Numbers differ strongly between runs noisy environment, warm-up not complete, background jobs longer steady state, repeat runs, isolate the environment
Dashboard empty wrong timestamp format or missing header row in the JTL save CSV with timestamp_format=ms and print field names

Exercise 1: spot the problems

Read this plan description and list every problem you can find, then compare with the answers in the code below.

TEXT
Thread Group: 300 threads, ramp-up 1 s, loop count forever, no scheduler duration
  HTTP Request  "HTTP Request"  GET http://localhost:8080/api/items
  HTTP Request  "HTTP Request"  POST /api/login   body {"user":"admin","password":"admin123"}
  HTTP Request  "HTTP Request"  GET /api/me         header Authorization: Bearer abc123
  View Results Tree  (enabled)
  Listener: Graph Results (enabled)
Python Stand-in: list of issues in Exercise 1

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Exercise 2: read the log

Which problem does each log excerpt describe? Match it to the catalogue.

TEXT
A) ERROR o.a.j.JMeterEngine: Error ... java.lang.OutOfMemoryError: Java heap space
B) WARN  o.a.j.p.http.sampler.HTTPSamplerBase: ... java.net.BindException: Address already in use: connect
C) ERROR ... javax.net.ssl.SSLHandshakeException: PKIX path building failed
D) ERROR o.a.j.r.RemoteSampleListenerWrapper: ... java.rmi.ConnectException: Connection refused to host: 127.0.0.1
E) INFO  ... Variable 'token' not found, using default 'TOKEN_NOT_FOUND'
Python Stand-in: a tiny log triage helper

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Exercise 3: the suspiciously good result

A test reports: 500 threads, average response time 12 ms, throughput 8,000 requests per second, error rate 0 percent. The service normally needs 150 ms for this call. What do you check? Think before you read on.

Likely causes: an assertion is missing and the replies are fast error pages with status 200; a cache or CDN is answering instead of the application; the request does not reach the real system (a proxy or wrong host); all requests ask for the same resource and hit a cache; the test is reading a stale JTL. Check the response bodies, the server's access log (does it show 8,000 requests per second?), and add a content assertion.

Exercise 4: the missing throughput

You expected 50 requests per second from 100 threads with 2-second think times, but get 40. Use Little's Law: each iteration takes about 2.0 s think plus the response time. If the average response time is 0.5 s, then R is 2.5 s and 100 threads give 100 / 2.5 = 40 requests per second. The plan is behaving correctly; the expectation forgot the response time. To get 50 per second you need 125 threads, or a Constant Throughput Timer set to the target rate.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. The first thing to do when a test misbehaves is...

    A single-thread run with View Results Tree removes concurrency and shows exactly what is sent and received.
  2. 2. Which tool shows all current variables as a response?

    The Debug Sampler outputs JMeter variables and properties, so you can see what was set.
  3. 3. Address already in use: connect points to...

    Too many short-lived connections use up ephemeral ports.
  4. 4. 500 threads, 12 ms average, 0 percent errors, but the service normally needs 150 ms. What is suspicious?

    Results far better than reality usually mean the test is not exercising the real code path.
  5. 5. 100 threads, 2 s think time, 0.5 s response. What throughput do you expect?

    100 / (2.0 + 0.5) = 40 requests per second.

Summary

  • Debug with one thread, View Results Tree, the Debug Sampler and the log files.
  • Most problems are unresolved variables, broken correlation, bad ramp-up, saturated generators or environment issues.
  • Match error messages to causes: heap, ports, TLS, RMI, timeouts.
  • Be suspicious of results that are too good, and check them against server-side facts.
  • Use Little's Law to check whether your expected throughput is even possible.

Next: back to the Apache JMeter track page