Code can pass functional tests and still fail under production load. Performance testing checks whether it meets speed and throughput requirements under a workload; load testing examines whether concurrent requests cause degradation. Tests should validate service-level objectives, not just demonstrate that the feature works. section 8.7.5 section 1.6
Measure before optimizing. Estimate production traffic, test both request frequency and latency, and use those measurements to identify work on the hot path. An isolated microbenchmark can compare implementations, while an end-to-end test measures the system as a whole. Neither makes an optimization worthwhile by itself: weigh the measured gain against operational complexity. section 7.1.1 section 7.2.3 section 7.5
A practical test cycle:
- Define the workload and objective: use traffic estimates, input sizes, and relevant service-level targets. section 7.1.1 section 7.2.3 section 1.6
- Measure a baseline with scenarios that exercise the relevant paths; check responses as well as latency. section 7.2.3
- Compare the changed implementation against the baseline under the same assumptions. Investigate high latency percentiles and the operational costs of any added concurrency. section 7.1.1 section 7.2.3
- Use longer runs for real systems than a short feedback benchmark. Include performance testing before major releases, and establish tests before modifying or migrating existing code. section 7.2.3 section 8.8.4 section 2.4
Finding the hot path
A service expects one word-of-the-day request per second and 20 word-exists requests per second. Estimated processing demand is 15 ms per second for the first endpoint and 720 ms for the second, making word-exists the stronger optimization candidate. Gatling scenarios exercise both endpoints for one minute to compare versions quickly; real-system tests should run substantially longer. section 7.2.3
Listing 7.10 Setting up the traffic profile
setUp(
wordOfTheDayScenario.inject(
constantUsersPerSec(1) during (1.minute)
),
validateScenario.inject(
constantUsersPerSec(20) during (1.minute)
)
).protocols(httpProtocol)The traffic profile makes the assumed request rates and short test duration explicit. section 7.2.3
A parallel shortcut that did not pay off
A JMH benchmark compared sequential and parallel account searches with 10,000 accounts. Their measured average times were nearly identical: 0.027 and 0.030 ms per operation, respectively. The parallel version did not justify added concerns such as thread-pool monitoring and harder debugging. section 7.1.1

