Question: How can you calculate the P90 latency?
Answer
P90 latency refers to the 90th percentile of response times in a distribution. It is a common metric used to evaluate the performance of databases, services, and applications.
To calculate P90 latency from a list of latencies in milliseconds, follow these steps:
- Sort the latencies in ascending order.
- Determine the index for the 90th percentile using the formula:
index = round((90/100) * len(latencies))
- Retrieve the latency at that index.
Here's a simple Python code example that demonstrates this:
def calculate_p90(latencies): sorted_latencies = sorted(latencies) index = round((90/100) * len(sorted_latencies)) return sorted_latencies[index-1] # Subtract 1 since indexing starts at 0 latencies = [15, 20, 35, 40, 50, 60, 70, 80, 100] print(calculate_p90(latencies)) # Output: 80
This method calculates the exact value at position P90. However, sometimes interpolation between adjacent values might be required if the computed index isn't an integer or if more precision is needed.
Please note that latency metrics like P90 are useful because they provide insights into the long tail of your latency distribution which average latency wouldn't reveal. A high P90 (or other high percentiles like P95 or P99) indicates that a significant portion of your users are experiencing high latencies, which could suggest performance issues.
Was this content helpful?
Other Common Database Performance Questions (and Answers)
- What is the difference between database latency and throughput?
- What is database read latency and how can it be reduced?
- How can you calculate p99 latency?
- How can one check database latency?
- How can you calculate the p95 latency in database performance monitoring?
- How can you calculate the p50 latency?
- What is the difference between p50 and p95 latency in database performance metrics?
- What is the difference between p50 and p99 latency?
- What is the difference between P90 and P95 latency in database performance?
- What is the difference between P50 and P90 latency in database performance?
- What is the difference between P90 and P99 latency in database performance metrics?
- What is the difference between p95 and p99 latency in performance metrics?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost