docs: add a section about latency and how it's measured (#16734)

closes https://github.com/coder/coder/issues/14942

- what latency is measured
- where it's reported
- how users experience latency
- how to lower latency



[preview](https://coder.com/docs/@14942-latency/admin/networking#latency)

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
This commit is contained in:
Edward Angert
2025-04-04 08:12:11 -04:00
committed by GitHub
co-authored by EdwardAngert
parent 42e5d71f59
commit 43d584c4f3
2 changed files with 67 additions and 0 deletions
+58
View File
@@ -197,6 +197,64 @@ low-latency browser experiences for geo-distributed teams.
To learn more, see [Workspace Proxies](./workspace-proxies.md).
## Latency
Coder measures and reports several types of latency, providing insights into the performance of your deployment. Understanding these metrics can help you diagnose issues and optimize the user experience.
There are three main types of latency metrics for your Coder deployment:
- Dashboard-to-server latency:
The Coder UI measures round-trip time to the Coder server or workspace proxy using built-in browser timing capabilities.
This appears in the user interface next to your username, showing how responsive the dashboard is.
- Workspace connection latency:
The latency shown on the workspace dashboard measures the round-trip time between the workspace agent and its DERP relay server.
This metric is displayed in milliseconds on the workspace dashboard and specifically shows the agent-to-relay latency, not direct P2P connections.
To estimate the total end-to-end latency experienced by a user, add the dashboard-to-server latency to this agent-to-relay latency.
- Database latency:
For administrators, Coder monitors and reports database query performance in the health dashboard.
### How latency is classified
Latency measurements are color-coded in the dashboard:
- **Green** (<150ms): Good performance.
- **Yellow** (150-300ms): Moderate latency that might affect user experience.
- **Red** (>300ms): High latency that will noticeably affect user experience.
### View latency information
- **Dashboard**: The global latency indicator appears in the top navigation bar.
- **Workspace list**: Each workspace shows its connection latency.
- **Health dashboard**: Administrators can view advanced metrics including database latency.
- **CLI**: Use `coder ping <workspace>` to measure and analyze latency from the command line.
### Factors that affect latency
- **Geographic distance**: Physical distance between users, Coder server, and workspaces.
- **Network connectivity**: Quality of internet connections and routing.
- **Infrastructure**: Cloud provider regions and network optimization.
- **P2P connectivity**: Whether direct connections can be established or relays are needed.
### How to optimize latency
To improve latency and user experience:
- **Deploy workspace proxies**: Place [proxies](./workspace-proxies.md) in regions closer to users, connecting back to your single Coder server deployment.
- **Use P2P connections**: Ensure network configurations permit direct connections.
- **Strategic placement**: Deploy your Coder server in a region where most users work.
- **Network configuration**: Optimize routing between users and workspaces.
- **Check firewall rules**: Ensure they don't block necessary Coder connections.
For help troubleshooting connection issues, including latency problems, refer to the [networking troubleshooting guide](./troubleshooting.md).
## Up next
- Learn about [Port Forwarding](./port-forwarding.md)
@@ -208,6 +208,15 @@ up to 60 seconds.
![Workspace proxy picker](../../images/admin/networking/workspace-proxies/ws-proxy-picker.png)
## Multiple workspace proxies
When multiple workspace proxies are deployed:
- The browser measures latency to each available proxy independently.
- Users can select their preferred proxy from the dashboard.
- The system can automatically select the lowest-latency proxy.
- The dashboard latency indicator shows latency to the currently selected proxy.
## Observability
Coder workspace proxy exports metrics via the HTTP endpoint, which can be