WebSocket handshake: initiated as an HTTP request with an Upgrade: websocket header. On a 101 response the connection is "upgraded" and both parties communicate over the same TCP connection using the WebSocket framing protocol.
2 / 5
What is a WebSocket frame?
Frame: the WebSocket protocol transmits data in frames with a tiny 2-10 byte header (opcode, mask bit, payload length). This per-message overhead is far smaller than HTTP headers sent with each request, making real-time messaging efficient.
3 / 5
What is the purpose of a WebSocket ping/pong?
Ping/pong: WebSocket control frames for heartbeating. The server periodically pings; if no pong arrives within a timeout, the connection is stale and is closed. This prevents zombie connections from consuming server resources.
4 / 5
What does it mean for a WebSocket to be full-duplex?
Full-duplex: unlike HTTP where the server only responds after a client request, WebSocket allows both parties to initiate messages at any time on the same connection. This enables true push from server without polling.
5 / 5
Why is horizontal scaling of WebSocket servers more complex than HTTP?
Sticky connections: a WebSocket client maintains a persistent connection to one server. When multiple servers exist, messages must be routed cross-server via a shared pub/sub system (Redis pub/sub, Kafka) so any server can broadcast to any client.