Guia de entrevista · Real-Time

How do you scale WebSockets?

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

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

An established connection has a selected backend, but the user receiving a message may be connected to a different server.

  1. Route events between servers using an appropriate broker or shared delivery service. A server then delivers an event only to its authorized connected recipients.
  2. Use session affinity when a transport or server-local session state requires it. Socket.IO's HTTP long-polling transport can need affinity across requests. A single established WebSocket does not require extra stickiness to keep its frames on that backend.
  3. Bound connection and message load, detect dead peers with heartbeats, and reconnect with backoff. Define presence expiry and graceful draining during deployment.

Authenticate the connection and authorize each room or operation. Re-check changing permissions. A valid connection does not grant access to every channel.

Trap: Redis Pub/Sub has at-most-once delivery. A disconnected subscriber misses events. Durable history needs storage and an application-level resume cursor, with ordering and replay deduplication defined explicitly.

Sources: Socket.IO multi-node deployment and Redis Pub/Sub delivery semantics.

Pegadinha clássica

Essa pergunta tem uma armadilha que derruba muita gente em entrevista. Ela está marcada na resposta acima: vale reler antes de treinar.

Ler é o primeiro passo. No app, essa pergunta vira flashcard com repetição espaçada, e o módulo tem quiz e simulado para testar o que ficou.

Treinar essa pergunta no app