Concepts · Concept

Websocket

-bidriectional

-its own protocol (not http)

-all infra need to support upgrading from http to websocket

-load balance, proxies, firewalls all need to negotiate this upgrade

-check on reconnect/initialize - pattern name: hybrid push + polling-as-safety-net

“WebSocket establishes a persistent, full-duplex (bidirectional) connection between client and server over a single TCP connection. Once the handshake completes, either side can send messages to the other at any time, with low overhead per message — no repeated HTTP headers like you’d get with polling.”

When to reach for it:

  • Communication genuinely needs to flow both directions — client sends data, server sends data, independently (e.g., a chat app, a collaborative editor like Google Docs, a multiplayer game)
  • Low-latency, frequent, small messages in both directions

Its weak spot: only works while the connection is actively open — the client (app/browser) must be running. If the app is fully closed (not backgrounded — closed), there’s no connection to push through at all (this is why Tinder’s match notification for an offline user needed APNS/FCM instead).