QA AND TEST AUTOMATION · PART 9 · NON-FUNCTIONAL TESTING · PERFORMANCE · 81 OF 112

Performance Metrics: p95, Throughput, Error Rate

Reading performance results correctly: response time percentiles (p50, p95, p99) and why averages hide slow users, throughput, error rate, concurrency and Little's law (checked against a real Locust run on ShopRung), server-side metrics like CPU, memory and saturation, turning numbers into goals (SLIs and SLOs), and comparing runs against a baseline.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Percentiles over averages
  • throughput
  • error rate
  • Little's law
  • server metrics
  • SLOs as thresholds
  • baselines

Notes

Percentiles

Sort every response time from fastest to slowest. The fiftieth percentile, or median, is the middle: half are faster. The ninety fifth percentile means ninety five percent were this fast or faster, and one in twenty was slower. The ninety ninth means one in a hundred was slower. These matter because one page view makes many requests, so almost every user meets the slow tail at some point.

Percentiles
  • sort all response times
  • p50 (median): half are faster
  • p95: 95% are faster; 1 in 20 is slower
  • p99: 1 in 100 is slower
  • max: one single worst request
  • a user makes many requests, so they WILL hit the p99

Averages hide

Here is our two hundred user stress run on ShopRung. The average was thirty five milliseconds, and the median was about the same. But the ninety fifth percentile was fifty seven, the ninety ninth sixty six, one request in a thousand took a hundred and ninety, and the slowest took three hundred and ten. An average of thirty five hides all of that. Report percentiles, and set goals on them.

Same run, different views
average      35 ms
p50          36 ms
p95          57 ms
p99          66 ms
p99.9       190 ms
max         310 ms

the average says 35;
1 request in 1,000 took 5x that

Throughput, errors

Throughput is how much work completes per second: requests per second, or business transactions like orders per second. Error rate is failed requests divided by all requests. A failure is not only a five hundred error or a timeout; a two hundred response with an empty product list under load is also a failure, so load scripts should check the body too. Fast answers that are wrong are not success.

Definitions
  • throughput: requests (or transactions) per second that completed
  • error rate: failed requests ÷ all requests
  • a failure: 5xx, timeout, OR a wrong answer (check the body, not just status)

Little's law

Little's law links the numbers: the number of users equals throughput times the time each request cycle takes, response time plus think time. Our fifty user run had an average think time of two seconds and responses of about two milliseconds, so it predicts fifty divided by about two, roughly twenty five requests per second. Locust measured twenty four point three. Use this to size tests and to spot results that cannot be right.

Checked on ShopRung
users = throughput x
  (response time + think time)

50 users, think 1-3 s (avg 2 s),
  response ~2 ms
predicted: 50 / 2.002
  ≈ 25 requests per second
measured:  24.3 per second

Server side

Client side numbers say what users feel; server side numbers say why. Watch CPU on every server, memory and garbage collection pauses, the database's slow queries, connection counts and locks, thread and connection pools, which create queues when full, and message queue lengths. Watch the load generators too. When response time rises, find the resource that is saturated first: that is the bottleneck.

Watch during the test
  • CPU per server, and steal
  • memory, garbage collection
  • DB: slow queries, connections, locks
  • pools: thread and connection pools full → queueing
  • queues and their length
  • the load generators too

Goals

Numbers need goals. An SLI, a service level indicator, is what you measure, like the ninety fifth percentile of checkout. An SLO, the objective, is the target: under eight hundred milliseconds, errors under one percent, at two hundred requests per second. Put these in the test as thresholds that fail the run, so CI can gate on them. Some teams also use Apdex, one score for how satisfied users are with response times.

From numbers to goals
  • SLI: what you measure (p95 of checkout)
  • SLO: the target (p95 < 800 ms, errors < 1%, at 200 req/s)
  • in the test: thresholds that fail the run (k6, JMeter assertions, Locust checks)
  • Apdex: one satisfaction score

Compare runs

A single number means little; a comparison means a lot. Save every run's results and compare against a baseline from the same script, data and environment. Did the ninety fifth percentile grow by twenty percent? Did throughput drop? Look at graphs over time, not only totals, because warm up and short spikes disappear in averages. And repeat a run before drawing conclusions; results vary from run to run.

Baselines
  • save each run's results
  • same script, data, environment
  • compare with the baseline: p95 +20%? throughput -10%?
  • look at time series, not just totals (warm-up, spikes)
  • one run is a sample: repeat before you conclude

Common mistakes

Metric mistakes. Reporting only averages. Averaging percentiles from several servers, which is mathematically wrong; combine the raw data instead. Counting every two hundred as success without checking the body. Including warm up in the totals. Collecting no server metrics, so nobody can explain the result. And drawing big conclusions from a single run.

Avoid these
  • averages only
  • averaging percentiles across servers (not valid)
  • 200 OK counted as success without checking the body
  • including warm-up in totals
  • no server metrics
  • one run, big conclusions

Say it like this

In the interview: I report median, ninety fifth and ninety ninth percentile response times per transaction, never just the average, along with throughput and error rate, where errors include wrong answers. Server CPU, memory, database and pool metrics explain the results. Goals are SLOs written as test thresholds, every run is compared with a baseline, and Little's law sanity checks the numbers.

In the interview
  • "p50, p95 and p99 response
  • times per transaction, never
  • just the average; throughput;
  • error rate including wrong
  • answers; and server CPU, memory, DB and pools to explain
  • them. Goals as SLOs and test
  • thresholds, results compared
  • with a baseline, and Little's
  • law to sanity-check numbers."

Interview questions

Q1What does p95 response time mean?

95% of requests completed in that time or faster; 1 in 20 was slower.

Q2Why are averages misleading for response times?

They hide the slow tail; a few very slow requests barely move the average but affect many users, who make many requests each.

Q3What is throughput?

The amount of work completed per unit of time, such as requests or transactions per second.

Q4What is Little's law in load testing?

Users = throughput x (response time + think time); it links concurrency, throughput and time and helps size and sanity-check tests.

Q5What counts as an error in a load test?

5xx responses, timeouts and connection errors, and also wrong responses, so scripts should check response bodies.

Q6What is the difference between an SLI and an SLO?

An SLI is the measured indicator, such as p95 latency; an SLO is the target for it, such as p95 under 800 ms.

Q7Can you average p95 values from several servers?

No. Percentiles cannot be averaged; combine the raw data or histograms and compute the percentile again.

Q8Which server metrics help explain slow responses?

CPU, memory and GC, database slow queries, connections and locks, thread and connection pools, and queue lengths.