Guia de entrevista · Real-Time

Polling vs Long Polling vs SSE vs WebSockets?

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

Essa é daquelas que parecem simples até o entrevistador emendar um "why?". Abaixo, a estrutura de resposta que passa em entrevista.

A resposta, como você fala na entrevista

Short polling: client asks every X seconds. Simple, wasteful, latency = the interval.
Long polling: client asks; the server HOLDS the request open until there's data; client immediately re-asks. Real-time-ish over plain HTTP.
SSE (Server-Sent Events): ONE long-lived HTTP connection, server → client only. Native browser API (EventSource) with auto-reconnect built in. Perfect for feeds, notifications — and LLM token streaming (this is what AI chat products use).
WebSockets: ONE persistent connection, FULL two-way (client ↔ server). For chat, games, collaborative editing, live payments.

Rule of thumb: only the server pushes → SSE. Both sides talk constantly → WebSockets. Neither → plain HTTP.

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