JMeter多机器压测结果如何聚合为单一报告?
Great question! When dealing with distributed load test results, merging them into a unified report requires careful handling of different metrics—simple averages won’t work for all columns. Let’s break this down step by step:
First: Which Metrics Can (and Can’t) Be Averaged Directly?
Not all metrics behave the same way when combining distributed results. Here’s how to handle each column from your CSV:
Sumable Metrics (direct addition):
#Samples: Total samples = sum of samples from all 4 machines (each machine runs independent users, so counts add up)Throughput: Total throughput = sum of each machine’s throughput (requests per second are additive across parallel machines)Received KB/sec&Sent KB/sec: Total network traffic = sum of each machine’s traffic valuesMin&Max: Total Min is the smallest value across all machines; Total Max is the largest value across all machines
Weighted Average Required:
Average(response time): A simple average of the 4 machine averages is inaccurate because machines with more samples have a bigger impact on the overall result. Instead, calculate a weighted average:Total Average = (Avg1 * Samples1 + Avg2 * Samples2 + Avg3 * Samples3 + Avg4 * Samples4) / Total SamplesError %: Total error rate is also a weighted average, based on total errors across all machines:Total Error % = (Samples1 * Error%1 + Samples2 * Error%2 + Samples3 * Error%3 + Samples4 * Error%4) / Total Samples
Cannot Be Averaged (Requires Raw Data):
Median,90% Line,95% Line,99% Line: These percentiles are calculated by sorting all individual response times and picking the value at the specified percentile. Averaging percentiles from each machine won’t give you the true overall percentile—you need the full set of raw response data (from merged .jtl files) to compute these accurately.
Recommended Methods to Generate a Single Report
1. Merge Raw .jtl Files (Most Accurate)
Even if each .jtl is over 300MB, merging them is the gold standard for precise results:
- Combine all 4 .jtl files into one (make sure to remove duplicate headers—only keep the first header row)
- Use JMeter’s built-in Dashboard generator with this command to create a comprehensive unified report:
jmeter -g merged.jtl -o report-folder
This will correctly calculate all percentiles, error rates, and other metrics using the full dataset.
2. Manual Weighted Calculation (If Raw .jtls Are Unavailable)
If you can’t access the .jtl files, you can compute key metrics manually using your CSV data. Let’s walk through your specific dataset:
- Total Samples: 34114 + 35537 + 34447 + 34454 = 138552
- Weighted Average Response Time:
(7200*34114 + 7927*35537 + 7189*34447 + 7316*34454) / 138552 ≈ 7412 ms - Total Error %:
(34114*0.1218 + 35537*0.1533 + 34447*0.1224 + 34454*0.1260) / 138552 ≈ 13.11% - Total Throughput: 14.61536 + 14.79504 + 14.72585 + 14.69896 ≈ 58.84 requests/sec
- Total Received KB/sec: 144.66 + 140.71 + 145.78 + 144.45 ≈ 575.6 KB/sec
- Total Sent KB/sec: 23.35 + 23.06 + 23.55 + 23.35 ≈ 93.31 KB/sec
- Total Min: 0 ms (smallest value across all machines)
- Total Max: 240417 ms (largest value across all machines)
For percentiles (Median, 90% Line, etc.), you can only report the range of values from the 4 machines as a reference—since you can’t compute true overall percentiles without raw data.
Why Simple Averaging Is Incorrect
Simple averaging works for metrics where each machine contributes equally, but for metrics tied to sample count (like average response time or error rate), machines with more samples have a larger influence on the overall result. In your case, the simple average of 7408 ms is close to the weighted average of 7412 ms, but the difference could be much bigger if one machine had significantly more samples than others.
内容的提问来源于stack exchange,提问作者ChanGan

