Question: What is the difference between P90 and P95 latency in database performance?


In the world of database performance and system monitoring, P90 and P95 are terms used to describe specific statistical percentiles. These figures provide insights into the distribution of latency values within a given data set.

P90 (or the 90th percentile) represents the value below which 90% of the observations may be found. For example, if the P90 latency of your database queries is 200 milliseconds, it means that 90% of your queries are completing in 200 milliseconds or less.

Similarly, P95 (or the 95th percentile) is the value below which 95% of the observations fall. If the P95 latency is 250 milliseconds, it indicates that 95% of your queries are completed within this time frame.

The higher the percentile, the closer you are to the maximum value in your distribution. Therefore, P95 will always be equal to or greater than P90. The difference between these two can help understand the consistency of your system's performance. For instance, if P90 is 200 ms and P95 is 300 ms, it could suggest that there's a subset of queries experiencing significantly higher latencies.

Here's an illustrative Python code using numpy to compute these percentiles:

import numpy as np # Let's assume you have collected latency data in milliseconds latency_data = np.array([150,170,220,210,260,280,290,230,205,220]) # Compute P90 p90 = np.percentile(latency_data, 90) print(f'P90 latency: {p90} ms') # Compute P95 p95 = np.percentile(latency_data, 95) print(f'P95 latency: {p95} ms')

The choice of percentile to consider depends on your specific requirements. If you want a general overview of performance for most users, P90 might be sufficient. However, if you're more interested in understanding the experience of slower queries or worst-case scenarios, higher percentiles like P95 or P99 could be more informative.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.