Rebalancing with maxLifetime
A reworked timeout system now allows two lightweight timeout settings for WebSockets; idleTimeout
(up to 16 minutes) and maxLifetime
(up to 4 hours):
idleTimeout
is how long (in seconds) a WebSocket may be idle (have no traffic) before it is considered closed.maxLifetime
is how long (in minutes) a WebSocket may be connected, before being gracefully closed by the server.
Specifying a value of 0 disables respective feature (the default for maxLifetime
).
Why use maxLifetime?
The idea here is to enforce a partial rebalancing, constantly forcing a few connections to reconnect via whatever load balancer in use. This is a strategy used by Netflix where they found success in having maxLifetime = 30
minutes.
Good values for the settings should be somewhere around 30-120 seconds idleTimeout
and 30-120 minutes maxLifetime
.