-
Notifications
You must be signed in to change notification settings - Fork 905
feat: set default workspace proxy based on latency #17812
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
Conversation
Auto select the proxy on first load, then defer to user selection. The auto selected proxy will not update again once set.
@@ -73,6 +74,8 @@ export const useProxyLatency = ( | |||
new Date(new Date().getTime() - proxyIntervalSeconds * 1000).toISOString(), | |||
); | |||
|
|||
const [loaded, setLoaded] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how I track when the latencies are done loading, since they all come back async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On first load should we just not show it until we auto-select? I think that would look better than the flicker.
@kylecarbs The flicker takes as long as the slowest proxy. If the slowest proxy is 2s, that feels like a long time to not be able to determine what proxy to use? Idk how the other FE components would react to a Tbh though, I don't think the flicker is that huge of a deal. It will only happen the first time you authenticate and load the page. Then we save the choice to local storage, and it never changes (unless you select something else). So the flicker happens once per user per device, and then never again. 🤷 |
This could give you suboptimal results because AFAIK, the latency measurement is only browser-to-proxy and doesn't include proxy-to-workspace. Imagine that you have workspaces and proxies in California and Maine. A Colorado user would always select the California proxy, even if the workspace is in Maine. |
Another interesting behavior is "auto selected proxy will not update again once set". I'd asssume if we have forward deployed engineers who travel to work with customers they'd need to select the proxy either way. Could there be a softer way to solve this? When you open the dashboard you get a "notification" or another UI indicator "We've detected a proxy with lower latency. Do you want to switch?" |
This is true. Workspace -> Proxy latency would be a better metric, but of course that would be different for different workspaces. It is only suboptimal if a user is between a workspace and a proxy geographically. The user in Virginia here always selects the proxy in the north east. But for them, that proxy is the opposite direction as for example the WorkspaceCentral workspace. The Cali user however, the Cali proxy is pretty much always optimal. In practice, since we can only select 1 workspace per user, it feels like selecting the closest proxy to the user is going to be the most correct without knowing more information. Regardless though, we have proxies today and we display latency of the user -> proxy. It does not make sense to our users that the default proxy selected has nothing to do with the latency presented.
We actually had a naive implementation of this originally: #8137 The issue is the latencies presented are not very consistent, and can easily "wiggle" +/-40ms. If you lived in US central, and you had a proxy on US east and US west. You could get this notification every page load as each coast can be better on any given ping. This inconsistency is why we disabled auto selecting proxies, because it was changing quite frequently for some users. And this changes the links of your apps, so it's not transparent to the user. This solution tries to find a balance between auto selecting and manual switching. We only auto select on first login (per browser, as we save to local storage). Then we let the user control it. The behavior today is we default to the primary Coderd, then let the user control it. So it's really just a minor QoL for first time Coder users. |
@ibetitsmike @spikecurtis @kylecarbs are any of your comments blocking? |
mine is not blocking |
@Emyrk not blocking too |
not blocking |
Auto select the proxy on first load (stored in local storage, so per browser), then defer to user selection. The auto selected proxy will not update again once set.
Closes #14827 (comment)
We initially reverted this here: #8137
We reverted because we used to auto select on each page load. So the workspace proxy could flip from page load to page load. This new change saves the auto selected proxy, and sticks to it. So it will be more stable of a selection
This is what it looks like on page load. Since latencies need to be loaded first, it does "flicker" on the first page load.
Screencast.From.2025-05-13.18-04-56.webm
Testing
The easiest way to test this is to run chromium without web security and use dev.coder.com as your
CODER_HOST
.chromium --disable-web-security
<- run chromedev.coder.com
with some proxies:CODER_HOST=https://dev.coder.com pnpm --dir ./site dev --host
const update = {