Easy shutdown with `app.close()` Calling this new function will:
Close and invalidate all open listen sockets. Force close all open connections (both HTTP and WebSockets), calling their respective callbacks as needed (.on_aborted, .close, .subscription). This call can be used to gracefully close and release an App that needs maintenance.
20.33.0
Rebalancing with max lifetime A reworked timeout system now allows two lightweight timeout settings for WebSockets; idle timeout (up to 16 minutes) and max lifetime (up to 4 hours):
idle timeout is how long (in seconds) a WebSocket may be idle (have no traffic) before it is considered closed. max lifetime is how long (in minutes) a WebSocket may be connected, before being gracefully closed by the server. Specifying a value of 0 disables the respective features (the default for max lifetime).
Why use max lifetime? The idea here is to enforce a partial rebalancing, constantly forcing a few connections to reconnect via whatever load balancer is in use. This is a strategy used by Netflix where they found success in having max lifetime = 30 minutes.
Good values for the settings should be somewhere around 30-120 seconds idle timeout and 30-120 minutes max lifetime.
20.32.0
Subscription events A new kind of event has been added. Whenever a `ws.subscribe` or `ws.unsubscribe` call is made, or when implicit unsubscription happens (such as when a WebSocket has subscriptions and gets closed in any way), a subscription event will fire with:
- the WebSocket involved - the topic name - the new number of subscribers to this topic - the former number of subscribers to this topic
These events can be used to easily manage external subscriptions such as when using Redis to orchestrate multiple instances of uWS. Whenever a subscription event with new subscription count == 1; you can create the corresponding Redis subscription. Whenever a subscription event with new subscription count == 0; you can free the corresponding Redis subscription.