Glossary

WebSocket

A protocol for a persistent, two-way connection between client and server over a single TCP socket.

1 min read·4 sections
Open the interactive version → diagrams, practice & more

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)…

Part of Glossary on SystemLore — system design explained with 148 deep topics, interactive diagrams, and a build-it-yourself game. Browse the glossary and "X vs Y" comparisons, or build this one →