Guia de entrevista · Real-Time

How do you scale WebSockets? (they will ask — it's on your resume)

do caderno de estudos · atualizado em 18 de julho de 2026
Para quem vai encarar entrevista de Real-Time2 min

Pergunta clássica de Real-Time em processo gringo. Não decore palavra por palavra: entenda a estrutura da resposta e refaça com as suas palavras, em inglês.

A resposta, como você fala na entrevista

The problem: connections are STATEFUL. User A is connected to server 1, user B to server 3 — how does A's message reach B?

  1. Sticky sessions at the load balancer: the same client always lands on the same server (the connection has to live somewhere).
  2. Pub/Sub backbone between servers (Redis pub/sub is the standard answer): server 1 publishes the message on a channel; every subscribed server delivers it to ITS connected clients. Socket.IO's Redis adapter is exactly this.
  3. Heartbeats (ping/pong) to detect dead connections + client reconnect logic with backoff.

Also mention: presence (who's online) tracked in Redis, and auth at the UPGRADE handshake — validate the token BEFORE accepting the connection.

Ler é fácil. Falar isso em inglês, sob pressão, com alguém avaliando, é outra história. No VagaGringa esse tópico vira flashcard com repetição espaçada, cai em quiz e entra no simulado.

Treinar este tópico no app