There was a similar thread started a few days ago How to limit the amount of active Websockets per node on Phoenix
LiveView builds on top of Phoenix Channels, so if you want to work out a solution from the client side have a look at phoenix 1.7.14 | Documentation. You can configure several aspects of how the Socket client works, for example the opts.reconnectAfterMs
function could be use to add jitter on top of the default exponential backoff.
I’d note however that like on the thread I linked above, we should probably be thinking at the overall system level – if you’re doing rolling deployments with Kubernetes, only a fraction of your currently connected users are being disconnected and then reconnected at a time, not all of them.
If the problem is concentrated around the database hits, another idea that comes to mind is using Phoenix.LiveView — Phoenix LiveView v0.20.17 or Phoenix.LiveView — Phoenix LiveView v0.20.17 to limit most of your queries to when the socket is connected, which could reduce the amount of queries by nearly half.