Description
Current behavior
When code-server loses the connection to the server, it attempts to re-connect at 30 second intervals repeatedly until the connection succeeds. If there is a large-scale event causing an outage while clients have code-server open, then this can cause repeated spikes in traffic on the server.
Steps to reproduce
- Open VSCode via master.cdr.dev
- Rebuild your environment while VSCode is open
While the environment is rebuilding, we just see this message every 30 seconds, counting down to zero and then restarting back at 30 seconds:
Proposed solution
We should consider applying a randomized exponential backoff scheme (e.g. try to reconnect in 10 seconds, then 20 seconds, then 40 seconds) to avoid coordinated events of large-scale deployments (hundreds or thousands of clients) hammering the server by attempting to reconnect at approximately the same time. This also allows us to begin with much smaller intervals to begin with (e.g. 5 seconds) making the reconnection much faster in the common case of a transient network issue.