LearnThatStack Ace your next interview
API Design · question
Question 72 of 92

What strategies do you use for API performance testing?

expert Pro
← All API Design questions

The full answer covers the core mechanics, when this pattern wins, and the trade-offs interviewers most often probe. It includes a code sample. Read it once at your own pace, then try to recall the structure from memory before the interview. Pro also includes this question's interview lens - the likely follow-up probes and what you can say in the room.

Full answer + code samples + AI explanations

Unlock to read the complete answer for this premium question.

Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Testing APIs: three different questions

Three suites, three questions: behaviour, compatibility, capacity. The contract test is the one only an API needs.

For this question · chapter 3 of 3

3/3 Four load shapes, four questions
performanceFour load shapes, four questionsone question per curvepeak traffic800rpsworst p95180msthe traffic you drive03,0006,000what comes back, p951003001k3k300 ms budget30 minutes at 800 requests per second1.4 M responses, all 200p95 under 300 mspass180 ms, all runerror rate under 0.1%pass0.00%the body matches the schemafailitems empty, total missingthe status is 200pass1.4 M of them, and it proves nothingevery response was a 200, and every body came back with items emptytwo of these four assertions never looked at the body at all
performanceFour load shapes, four questionspeak traffic800rpsworst p95180msthe traffic you drive03,0006,000what comes back, p951003001k3k300 ms budget1.4 M, all 200what to assertp95 under 300 mspasserrors under 0.1%passbody matches schemafailthe status is 200pass, proves nothingevery body: items empty, total missing

Four load shapes, four questions

  1. Two suites have now proven behaviour and compatibility. Capacity is a different question. You ask it with the shape of the traffic. A load test keeps the traffic at the level you actually expect: 800 requests per second for 30 minutes. The p95 latency (the time within which 95% of requests finish) stays at 180 ms, under a 300 ms budget. So this run tells you about a normal day and nothing else.
  2. A stress test gives two numbers, and the second one matters more. The first is the ceiling, 3,000 requests per second, where latency goes over the budget as the traffic keeps rising. Latency then stays over the budget and reaches 4,900 ms at the top of the ramp. The second number is the first thing to break, the database pool at 200 connections.
  3. A spike test measures recovery, not the peak. Traffic rises from 800 to 5,000 requests per second in ten seconds and stays there for thirty seconds. Under that load, the p95 reaches 4,100 ms and 11% of requests fail. But the measurement is the 90 seconds the service takes to get back under the budget after the spike ends.
  4. This endurance run finds a leak, and no ten minute run can show a leak's shape. The test sends the same ordinary traffic for eight hours. But p95 latency still rises from 180 ms to 940 ms, and the heap grows in a straight line from 410 MB to 3.1 GB. People skip this test, but it explains why a service needs a restart at 3am.
  5. A test that checks only the status code proves almost nothing. Every signal says the load run passed: 1.4 million responses, all of them 200, and p95 at 180 ms. Only the schema assertion failed, because every response body had an empty items list and no total field. So assert an error rate, the body's shape, and a percentile instead of an average, because an average hides every slow response.
Chapter 3 · step 1 of 5

Two suites have now proven behaviour and compatibility. Capacity is a different question. You ask it with the shape of the traffic. A load test keeps the traffic at the level you actually expect: 800 requests per second for 30 minutes. The p95 latency (the time within which 95% of requests finish) stays at 180 ms, under a 300 ms budget. So this run tells you about a normal day and nothing else.

1 of 5 Use ← → or swipe See the concept: all 3 chapters in it

© LearnThatStack - diagrams may not be republished without permission.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

74 of 92 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime