Question: What is P90 latency in database performance?

Answer

"P90 latency," also sometimes referred to as the 90th percentile of latency, is a statistical measure used to understand the performance characteristics of a system, such as a database or a network. It provides a threshold under which 90% of the observed latency measurements fall.

In the context of a database, P90 latency tells you that 90% of your database queries are executed within this specified latency. For example, if the P90 latency for a given set of database operations is 200 milliseconds, it means that 90% of these operations have completed within 200 milliseconds.

P90 latency is particularly useful because it can help isolate and understand outliers. While average (or mean) latency can give you a general sense of how your system performs, it may not fully capture the experience of users if there are occasional instances of high latency. Using P90 (or other percentiles like P95 or P99) can give a much better understanding of these outliers, thus allowing you to optimize your database more effectively.

Here's a simple Python example of how to calculate P90 latency from a list of latency measurements:

import numpy as np # let's assume latencies is a list of your measured latencies latencies = [...] # calculate P90 p90_latency = np.percentile(latencies, 90)

In this example, np.percentile is a function from Python's NumPy library that computes the nth percentile of a list of values.

In conclusion, P90 latency is a valuable metric when assessing database performance as it provides insights into the behavior of the majority of transactions, mitigating the impact of extreme outliers that could skew an average latency calculation.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today

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