Prerequisites
What it is
WebSocket is a protocol that upgrades an HTTP connection into a long-lived bidirectional connection. Both client and server can send messages without opening a new request each time.
Why it matters
It is the standard choice for chat, presence, multiplayer coordination, collaborative editing, and live dashboards where polling would be too slow or wasteful.
How it works
The client performs an HTTP upgrade handshake. After that, frames travel over the same TCP connection until either side closes it. Servers track connection ownership and route events to the right socket.
When to use it
Use WebSocket when clients need frequent server-pushed updates or client messages with low latency.
Tradeoffs / failure modes
Long-lived connections complicate load balancing, deploys, backpressure, authentication refresh, and regional failover.
Tiny example
A chat client opens one socket, sends typing indicators, and receives new messages as soon as they are delivered.
Related guides and systems
See WebSocket Infrastructure, Presence, Collaborative Editing, Server-Sent Events, WhatsApp, Slack, Discord, Google Meet, and Zoom.
Seen in deeper dives
Capability
Collaborative Real-Time Editing
CRDTs vs Operational Transform for conflict-free concurrent document editing
Capability
Presence & Online Status
Distributed heartbeat tracking to show who is online in real time
Capability
Server-Sent Events
One-way real-time streaming from server to client over HTTP
Capability
WebSocket Infrastructure
Persistent bidirectional connections at scale for real-time applications
Case Study
Discord
Real-time voice, video, and text for communities at massive scale
Case Study
Google Meet
WebRTC-powered video conferencing deeply integrated with Google Workspace
Case Study
Slack
Channel-based messaging for the enterprise workplace
Case Study
End-to-end encrypted messaging at planetary scale
Case Study
Zoom
Proprietary multimedia routing for reliable video conferencing at any scale
Related concepts
Pub/Sub
Broadcast events from publishers to many independent subscribers.
CRDT
Let distributed replicas accept local edits and merge without conflicts.
Operational Transform
Transform concurrent edits so collaborative documents preserve user intent.