Skip to main content

Glossary

WebSocket

Meaning and details

WebSockets solve HTTP's one-way constraint. Normal requests open, ask, answer and close; a WebSocket handshake upgrades the connection to a permanent channel where either side sends at any time, with tiny frames instead...

WebSocket meaning

A protocol that upgrades an HTTP connection into a persistent two-way channel, letting server and client push messages any time.

What is WebSocket?

WebSockets solve HTTP's one-way constraint. Normal requests open, ask, answer and close; a WebSocket handshake upgrades the connection to a permanent channel where either side sends at any time, with tiny frames instead of full requests. That is the primitive under chat, collaborative editors, live dashboards, multiplayer cursors and trading interfaces, anywhere the server must speak unprompted.

Why it matters to an indie builder: real-time is a product feature that feels like magic and costs surprisingly little with the right primitives, Phoenix Channels, Pusher, Ably and the realtime layers inside Supabase handle the hard parts, reconnection, presence, fan-out. The engineering decision is honest about the cost: each open connection holds state server-side, horizontal scaling needs a pub/sub backbone like Redis, and the failure modes, silent drops behind load balancers, half-open connections, move from rare to daily.

A concrete example: a delivery-tracking page. Polling version: the client asks every five seconds, three requests per minute per watcher, most returning nothing new, and updates lag up to five seconds. At 2,000 concurrent watchers that is 6,000 requests a minute of mostly empty answers. WebSocket version: the server pushes a position event to each watcher when it happens, roughly one message per minute per active delivery, updates land in under 200 milliseconds, and infrastructure load drops by an order of magnitude. The feature changed category, from periodically refreshed to live.

Common mistakes: websockets for everything when server-sent events fit the one-way case with less machinery, no heartbeat and reconnect logic (dead connections accumulate invisibly until the server drowns), no authentication on the socket itself (the handshake is an HTTP request; guard it like one), and missing the scaling plan, the first load balancer that does not support upgrade headers will break the product the night you launch. The real-time trait blocks on IndieBoot mark the services that take this off your plate.

Keep exploring the glossary