ruk·si

🕳️ WebSockets

Updated at 2016-01-03 23:20

WebSockets allow duplex connection between client and server.

Use WebSockets sparingly. WebSockets are not a straight-up improvement from normal requests, there are trade-offs mentioned further down.

Debugging WebSockets is a lot harder than debugging requests.

Web browsers allow easily over 200+ WebSockets per host by default. This means when a user opens your site in multiple tabs, all WebSockets are duplicated. This is why you should design your website to use only a single WebSocket, and even this might be too much to handle. You should make WebSockets to close down when not used for a while and reconnect as needed as user views the tab again.

Each WebSocket connection simply cannot have an ongoing database connection. You will hit database connection limit really fast. Only read cached values and make another process update that cache.