Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025

Conversation

EdwardAngert
Copy link
Contributor

@EdwardAngert EdwardAngert commented Feb 27, 2025

closes #14942

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

preview

@EdwardAngert EdwardAngert added the docs Area: coder.com/docs label Feb 27, 2025
@EdwardAngert EdwardAngert self-assigned this Feb 27, 2025
@github-actions github-actions bot added the stale This issue is like stale bread. label Mar 7, 2025
@EdwardAngert EdwardAngert removed the stale This issue is like stale bread. label Mar 10, 2025
@EdwardAngert
Copy link
Contributor Author

this one's a blend of trolling through discussions, issues, and code along with a mix of guessing and Claude, but it should get us started


- Dashboard-to-server latency:

The Coder UI measures round-trip time to the Coder server using the browser's Performance API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coder server or workspace proxy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to

The Coder UI measures round-trip time to the Coder server
+ or workspace proxy
using the browser's Performance API.

L208


The Coder UI measures round-trip time to the Coder server using the browser's Performance API.

This appears in the user interface next to your username, showing how responsive the dashboard is.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit more complex if there are multiple workspace proxies. The dashboard is always served from the primary Coder server deployment, which will be one specific entry, although I don't think we do anything special to indicate which one, unfortunately.

The other workspace proxies serve applications from the workspace, like web IDEs, the web terminal, etc. A low ping there will help those applications be more responsive, but it only measures part of the round-trip. The proxy to workspace leg is not measured.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had trouble figuring out how to add that to this doc in a way that doesn't take it too far off course, so I added it to workspace-proxies.md in 9e7dc7b

I also force-pushed to this branch because I repointed it to main so that the latency info isn't tied to a rework of the networking docs in general. hopefully I did that as cleanly as possible 🤞

- Workspace (direct P2P connection when possible)
- DERP relay servers (when P2P isn't possible)

This latency is visible in workspace cards and resource pages. It shows the round-trip time in milliseconds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've looked into this, and admittedly I'm a bit embarassed by what we built.

The latency on the Agent resource card is between the Agent and the shown relay. It never shows P2P (which isn't possible to achieve via the web browser anyway).

The estimated total latency if you were to access a workspace via the browser would be if you added the numbers by your username to the numbers you see in the Agent card, then that would give you a rough picture of the total latency thru various relays.


- **Deploy workspace proxies**: Place [proxies](./workspace-proxies.md) in regions closer to users.
- **Use P2P connections**: Ensure network configurations permit direct connections.
- **Regional deployments**: Place Coder servers in regions where most users work.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful with the pluralization here. There should only be one Coder server deployment, located somewhere close to the most users. It can have multiple replicas for scale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/coder/coder/pull/16734/files#diff-f2e36a38235181ed6696007214d293eda4ee5e9c5d8ecb9665b799beaeae8e54R250-R253

- **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.

@github-actions github-actions bot added the stale This issue is like stale bread. label Mar 27, 2025
@EdwardAngert EdwardAngert removed the stale This issue is like stale bread. label Mar 28, 2025
@EdwardAngert EdwardAngert changed the base branch from 16634-networking-stack to main April 2, 2025 20:24
@EdwardAngert EdwardAngert changed the base branch from main to 16634-networking-stack April 2, 2025 20:28
@EdwardAngert EdwardAngert changed the base branch from 16634-networking-stack to main April 2, 2025 20:29
Comment on lines 214 to 222
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.

Total end-to-end latency experienced by a user is a combination of dashboard-to-server latency plus this agent-to-relay latency.

- Database latency:

For administrators, Coder monitors and reports database query performance in the health dashboard.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've looked into this, and admittedly I'm a bit embarassed by what we built.

The latency on the Agent resource card is between the Agent and the shown relay. It never shows P2P (which isn't possible to achieve via the web browser anyway).

The estimated total latency if you were to access a workspace via the browser would be if you added the numbers by your username to the numbers you see in the Agent card, then that would give you a rough picture of the total latency thru various relays.

@spikecurtis copying your comments over so they don't get lost

I removed the lines you had commented on, and replaced them with this. Do you think it helps to point out not direct P2P connections or should we cut that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "not direct P2P connections" is useful.

The only direct improvement I have to suggest is maybe indicate that the end-to-end latency calculation is an estimate, not a hard mathematical reality. "You can estimate the total end-to-end latency by adding..."

@EdwardAngert EdwardAngert requested a review from spikecurtis April 3, 2025 18:28
Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the best we can hope for given the state of the product!

@EdwardAngert EdwardAngert merged commit 43d584c into main Apr 4, 2025
33 checks passed
@EdwardAngert EdwardAngert deleted the 14942-latency branch April 4, 2025 12:12
@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs Area: coder.com/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Clarify what latency measurement in Coder UI represents
2 participants