💡 If you like this website, please share it with your friends and network! 🚀
Back to All Questions
Question 82 of 100
API Performance & Load
Advanced

Q82: How Do You Measure API Throughput and Latency?

📊Core Concept

How Do You Measure API Throughput and Latency?

Key Takeaways & Architecture Summary

  • Throughput: Measures the number of requests processed per second (RPS).
  • Latency: Measures the round-trip response delay in milliseconds.
  • Track p95 and p99 percentiles to see real-world user performance.

Direct Answer Summary

Throughput is measured as the volume of requests the API can process per second (RPS). Latency measures the round-trip connection time. During load runs, engineers analyze these metrics using percentiles (p95, p99) rather than simple averages to identify slow requests.

⚠️ Senior Engineering Warning (Red Flag)

Avoid using simple mathematical averages to analyze API latency. Averages hide performance spikes; use percentiles (like p95 or p99) to see how the slowest requests perform.

💡 STAR Architectural Explanation & Pro Tip

A p99 latency of 112ms indicates that 99% of requests completed in 112ms or less, while only 1% took longer. This provides a clear metric for real-world user experiences.

RestAssuredTest.java
Rest-Assured + Java
# k6 CLI output showing percentile latency metrics
# http_req_duration..............: avg=21ms min=5ms med=12ms max=820ms p(95)=45ms p(99)=112ms