Definition
A protocol for a persistent, two-way connection between client and server over a single TCP socket.
How it works
After an HTTP upgrade handshake, both sides can push messages anytime with low overhead — ideal for chat, live dashboards, multiplayer and notifications. The cost is stateful connections: you must track which server holds which socket (sticky routing or a pub/sub fan-out layer) and handle reconnects. For server→client-only streams, SSE is simpler.
Common questions
What is WebSocket?
A protocol for a persistent, two-way connection between client and server over a single TCP socket.
How does WebSocket work?
After an HTTP upgrade handshake, both sides can push messages anytime with low overhead — ideal for chat, live dashboards, multiplayer and notifications. The cost is stateful connections: you must track which server holds which socket (sticky routing or a pub/sub fan-out layer)…
What is WebSocket used for in system design?
After an HTTP upgrade handshake, both sides can push messages anytime with low overhead — ideal for chat, live dashboards, multiplayer and notifications. The cost is stateful connections: you must track which server holds which socket (sticky routing or a pub/sub fan-out layer)…