# Latency
Latency is the most critical performance metric for realtime messaging platforms.
That doesn't mean just hitting a one-off figure to advertise. It's about providing **consistently low latencies** to all regions, for all use cases, all the time.
Ably's platform achieves this by providing the lowest latencies of any Pub/Sub WebSockets platform, with a **global median latency of 37ms**.
Understand how Ably optimizes its transit latency to consistently provide your users with the best possible realtime experience.
## Why latency matters
In realtime applications, latency directly impacts user experience and application responsiveness. Whether it's live chat, collaborative editing, multiplayer gaming, or financial trading, your users expect near-instantaneous message delivery. Even a small increase in latency can significantly degrade the perceived quality of your application.
## Latency metrics
Ably measures and optimizes for two latency metrics to ensure consistent performance across the platform:
### Round-trip latency
Round-trip latency measures the total time it takes for a message to travel from a publisher, through Ably's infrastructure, to a subscriber, and back again.
#### Round-trip latency - Last 7 days
### Message delivery latency
Message delivery latency measures the time taken from when a message is published to Ably until it is delivered to a subscriber.
This metric focuses on the core messaging performance without including the return path.
#### Message delivery - Median latency - Last 7 days
#### Message delivery - P90 latency - Last 7 days
## How latency is measured
Ably employs rigorous measurement methodologies to ensure latency performance is accurately captured across its global platform.
Latency measurements are taken continuously at the following rates:
* 70 measurements per second.
* 4,200 measurements per minute.
* 252,000 measurements per hour.
* 6,048,000 measurements per day.
### Round-trip latency measurement
Round-trip latency is measured using real browser monitoring through Uptrends Real Browser Monitoring. This approach provides:
* **Real browser simulation**: Measurements are conducted using actual browser instances, ensuring realistic network conditions.
* **Global coverage**: Monitoring points are distributed across the globe using a third party service.
* **Pub/sub simulation**: Real browsers publish messages and measure the complete round-trip time.
* **Continuous monitoring**: Measurements are conducted continuously to capture performance across different time periods and load conditions.
This methodology ensures that round-trip latency measurements reflect the actual experience of end-users accessing Ably through web browsers.
### Message delivery latency measurement
Message delivery latency is measured using Ably's internal quality of service (QOS) application. The measurement process includes:
* **Continuous message publishing**: Messages are sent continuously to a common Ably channel at a rate of 5 messages per second, per region.
* **Payload inclusion**: Each message contains a payload with region information and precise publish timestamp.
* **Delivery tracking**: Subscribers across different regions receive and timestamp the messages.
* **Latency calculation**: Delivery latency is calculated by subtracting the publish timestamp from the delivery timestamp.
* **Statistical sampling**: The 5 messages per second rate ensures statistically relevant sample sizes across all regions.
This methodology provides comprehensive coverage of Ably's global infrastructure and ensures that latency measurements reflect real-world conditions across all datacenters and regions.
### Measurement infrastructure
Both measurement systems operate continuously to provide realtime insights into Ably's latency performance. They include:
* **Automated collection**: Measurements are collected automatically without manual intervention
* **Realtime analysis**: Latency data is processed and analyzed in realtime
* **Alerting**: Performance thresholds trigger alerts when latency exceeds targets
* **Historical tracking**: Long-term trends are maintained for performance optimization
### Statistical analysis
Latency data is analyzed across multiple percentiles to ensure comprehensive performance reporting:
* **P50 (median)**: Represents typical performance under normal conditions.
* **P90**: Ensures 90% of messages meet performance targets.
This multi-percentile approach ensures that Ably's latency performance is consistent and predictable across all load conditions.