Video in progress

How do you plan a load test for a microservice system: in which environment, with what data and traffic profile, and how do you judge the result?

I start from the goal: which question needs an answer: a capacity limit, readiness for a peak, or a regression. You need scenarios that replay the real traffic mix, data volume close to prod and a suitable environment, and the result is judged not by RPS alone but by SLOs, the saturation point and the first resource to run out.

📖 Answer

Many load tests end up hammering one endpoint and concluding "it handled 5000 requests per second". In prod, though, checkout falls over twice a day, because in real traffic 60% is catalog reads, 25% cart and 10% checkout, and they put different load on different DBs.

Planning:

  1. The question. "Will we survive 5 times the traffic on a sale day?" is a peak test. "Did this release make latency worse?" is a regression test, run weekly, at small volume. "At what point and how do we fall over?" is a stress test. They are built differently.

  2. The traffic profile comes from prod: the share of each endpoint, user journeys (in k6 or Gatling, "catalog → product → cart → checkout" scenarios), think time. The load model must be open (N new users per second). In a closed model (N virtual users loop), if the system slows down the generator itself sends fewer requests and the problem is hidden.

  3. Data. On an empty DB everything is fast. Tables must be at prod volume, and caches with a real hit ratio: a test with 1000 identical product IDs makes the cache 100% and ruins the result.

  4. The environment. Ideal is a staging equal to prod. In practice it's often smaller, and scaling the result isn't linear. Some organizations test in prod, at low-traffic hours, with marked synthetic orders. This takes serious preparation such as separating synthetic data, stubbing external providers and a kill switch.

  5. External dependencies: a stub or sandbox for the payment provider and SMS, otherwise real money and real SMS go out.

Judging:

  • by SLO: up to what load p99 and the error rate stay within limits;
  • the saturation point: where throughput stops growing as load increases and latency shoots up;
  • the first resource to run out: DB connections, CPU, a thread pool, Kafka partitions, an external API limit. This is the most valuable result, because it shows where to invest;
  • the shape of the failure: after the load drops, does the system recover on its own or does it need a manual restart?

Measure the load generator too: if its CPU is at 100%, the result is the generator's, not the system's. Save results so they can be compared with earlier tests: the trend is what's valuable, not a single test.