DEV Community

Cover image for Long polling vs WebSockets vs SSE for system design interviews, explained
Gowtham Potureddi
Gowtham Potureddi

Posted on

Long polling vs WebSockets vs SSE for system design interviews, explained

Long polling vs WebSockets vs SSE for system design interviews, explained

Design a chat app, a live notification feed, or a presence indicator, and you hit the limit built into the web itself: HTTP is request/response, so the client has to ask for data — the server can never push on its own. The moment a feature needs the server to tell the client "something changed" without being asked, you have to pick a real-time transport, and the interview question is which one and why. The three answers that matter are long polling (the client holds a request open until the server has data), Server-Sent Events / SSE (one long-lived connection the server streams events down, one-way), and WebSockets (a single upgraded TCP connection that is full-duplex, both directions at once). Comparing long polling vs WebSockets and WebSockets vs SSE is a core real time communication system design probe because the easy answer — "use WebSockets" — is usually the wrong one, and knowing when each fits is the signal.

The reason it comes up is that real-time features are everywhere — chat, notifications, live scores, collaborative editing, dashboards — and each one has a different communication shape. Some need data to flow only server→client (a notification feed); some need it both ways (a chat or a game). Pick a transport heavier than the shape requires and you pay for infrastructure you did not need; pick one lighter and the feature does not work. This guide walks what a strong candidate names out loud: why plain HTTP can't push, the ladder of options from short polling up to WebSockets, the decision guide that maps a feature to a transport, and the scaling reality that persistent connections turn a stateless service into a stateful connection fleet.

Title card for a system design interview explainer on long polling vs WebSockets vs SSE, showing three real-time transports side by side — long polling as a held-open HTTP request, SSE as a one-way server-push stream over HTTP, and WebSockets as a full-duplex upgraded TCP connection — with a note that the server, not the client, needs to push, on a dark citrus-and-lavender background.

Why real-time transports come up in system design interviews

The transport choice rarely gets its own prompt. It appears inside a design — "design a chat app," "design a live notification system," "design a sports-score feed" — the moment the interviewer asks how the client learns about new data. You say "the client polls the server," and the follow-up is the trap: polling every few seconds is either laggy or wasteful, so how do you deliver updates in real time without hammering the server? That is where long polling, SSE, and WebSockets enter, and the interviewer wants the one that fits the feature, not the most powerful one you can name.

The interviewer rarely lets "I'll use WebSockets" stand on its own. "You built live notifications with WebSockets. It works, but it's expensive and complex to scale — you're holding a stateful connection open for every user. The data only ever flows server→client; a notification goes down, nothing comes back up. Did you need WebSockets at all?" That question — matching the transport to the direction of the data — is the one a memorised "use WebSockets" answer can never survive.

The rounds on Zynter are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: you name a transport, and the next sentence attacks the direction of data flow, the connection overhead, or what happens to a million open connections when a server restarts.

What the interviewer is really testing

A real-time transport answer is read on the same four dimensions as any design decision. Problem solving — did you reach for the lightest transport that fits the data flow, or default to WebSockets for everything? Communication — can you say in one sentence the difference between one-way SSE and full-duplex WebSockets? Technical execution — do you handle the scaling cost of persistent connections, sticky sessions, and a connection registry? Time management — did you spend your words on the decision and its trade-off, not on the WebSocket handshake bytes? Reading this guide teaches the concepts; it does not teach you to defend a transport choice while someone pushes on the scaling cost.

The problem: HTTP is request/response, so the server can't push

Start with why this is hard, because every transport is a workaround for the same limitation. Plain HTTP is a request/response protocol: the client opens a connection, sends a request, the server sends one response, and the exchange is done. The server has no channel to initiate anything — it can only answer. So for any feature where the server learns something new (a message arrived, a price moved, a friend came online), it has no way to tell the client, which is sitting there not asking.

The naïve fix is short polling: the client asks "anything new?" every N seconds on a fresh request. It is trivial to build on normal HTTP and works everywhere, but you must say why it is bad:

  • It is wasteful — most requests return "nothing new," so you spend connections, bandwidth, and server CPU on empty answers, and every request re-sends headers and re-does auth.
  • It is laggy — an update that lands just after a poll waits the full interval before the next poll sees it, so your real-time feature is only as fresh as your polling period.
  • The two pull against each other — poll faster for freshness and you waste more; poll slower to save load and you add lag. There is no setting that is both cheap and real-time.

The sentence that scores: HTTP is request/response, so the server can't push — the client must ask. Short polling fakes it by asking on a timer, but that trades waste against lag with no good middle, so for anything truly real-time I move up the ladder to long polling, SSE, or WebSockets. Naming the request/response limit and why short polling is the floor, not the answer, is what frames the rest of the comparison.

Short polling and long polling: faking push over plain HTTP

Long polling is the clever upgrade that still lives entirely within HTTP. The client sends a request, but instead of answering immediately, the server holds the request open until it actually has data to send (or a timeout fires). When data arrives, the server responds, and the client immediately sends another request to wait again. The effect is near-real-time delivery: an update reaches the client as soon as it exists, not on the next tick of a timer.

  • Short polling — fixed-interval requests, each answered right away, most returning nothing. Simple and universal, but wasteful and laggy.
  • Long polling — the request is parked server-side until there is something to send. You get push-like latency, and it works over plain HTTP through every proxy, firewall, and old browser — no special protocol.

The cost is in the churn. Each delivered message still means a full request/response cycle — a new connection setup, a fresh round of headers and auth — and between messages the server is holding open connections that consume resources. Under high message rates, long polling degrades toward short polling's overhead, and a burst of simultaneous messages can mean a thundering herd of re-requests. The sentence that scores: long polling holds the request open until data exists, so it delivers near-real-time over ordinary HTTP with no new infra — but every message is still a separate request with header and connection overhead, so it's the right call when updates are infrequent or you can't change the infrastructure, not when they're constant.

A diagram contrasting short polling with long polling, showing short polling as the client sending a request every few seconds and the server answering immediately, mostly with empty "nothing new" responses that waste bandwidth and add lag; versus long polling where the client sends one request and the server holds it open until data is ready, then responds and the client immediately re-requests, delivering near-real-time updates over plain HTTP at the cost of connection churn and repeated header overhead.

System Design
HLD · Core concept
Explain short vs long polling and their overhead out loud

Practise on Zynter →

SSE and WebSockets: real server push

Both long-polling styles still open a fresh request per message. The next step up keeps one connection open and pushes over it — and here the comparison splits on direction.

  • Server-Sent Events (SSE) — the client opens a single long-lived HTTP connection and the server streams a sequence of events down it, one-way, server→client. It is built on plain HTTP (works through most proxies), the browser's EventSource auto-reconnects and can resume from the last event id, and it is text only. The limits: it is one-directional (the client still sends data with a normal separate request), and browsers cap concurrent connections per domain (classically ~6 over HTTP/1.1, relaxed under HTTP/2), which matters at scale.
  • WebSockets — the client sends an HTTP request with an Upgrade header, and on success the connection is upgraded to a single persistent TCP connection that is full-duplex: both sides can send, independently, at any time, with low per-message overhead (small frames, no repeated headers) and support for binary or text. The cost is infrastructure: it is a stateful, long-lived connection, so it needs its own handling — sticky sessions or a connection registry, load balancers that understand the protocol, and a plan for scaling the connection fleet.

The sentence that scores: SSE is one long-lived HTTP connection the server streams events down, one-way and text-only, with built-in auto-reconnect — perfect for feeds and notifications; WebSockets upgrade to a single full-duplex TCP connection where both sides push with low overhead — needed for chat, games, and collaboration — but you pay for it with stateful connections, sticky sessions, and a connection fleet to scale. Knowing that SSE is the lighter, HTTP-native, one-way option and WebSockets the heavier, bidirectional one is the whole comparison.

A comparison diagram of WebSockets versus SSE, with WebSockets showing a single TCP connection upgraded from an HTTP handshake carrying full-duplex frames in both directions with low overhead and binary or text payloads, noted as needing stateful connections and sticky sessions; and SSE showing one long-lived HTTP connection over which the server streams a one-way sequence of text events to the client with automatic reconnection, noted as HTTP-native and limited by per-domain connection caps.

System Design
HLD · Core concept
Contrast one-way SSE and full-duplex WebSockets out loud

Practise on Zynter →

Choosing a transport: the decision guide

With the ladder in hand, the interview turns on matching the feature to the lightest transport that fits. Drive the choice off two questions — which direction does data flow, and what constraints and scale are you under:

  • Server→client only (notification feeds, live scores, a stock ticker, activity streams, progress updates) → SSE. One-way is exactly its shape, it rides on HTTP, and auto-reconnect is free. Reaching for WebSockets here is the classic over-build.
  • Bidirectional / interactive (chat, multiplayer games, collaborative editing, live cursors, trading) → WebSockets. When both sides push frequently and latency matters, full-duplex with low overhead is the only fit.
  • Can't change the infrastructure, or updates are rare (a legacy stack, strict proxies, an occasional status change) → long polling. It needs no new protocol and works everywhere, and if messages are infrequent the connection churn barely bites.

The sentence that scores: I map the feature to the data direction first — one-way server push is SSE, bidirectional interactive is WebSockets — and I only drop to long polling when I can't run persistent-connection infra or updates are too rare to justify it. The default mistake is WebSockets for a feed that only ever flows one way. Naming the direction-first rule, and the over-build trap, is the judgment signal the whole topic is testing for.

A decision-guide diagram for choosing a real-time transport, showing a branch on data direction: server-to-client only leads to SSE for feeds, notifications and live scores; bidirectional and interactive leads to WebSockets for chat, games and collaboration; and a side branch for cannot-change-infrastructure or rare updates leads to long polling, with a footer note to pick the lightest transport that fits the data flow and to weigh the scaling cost of persistent connections.

The scaling note: from stateless HTTP to a stateful connection fleet

The trade-off the strongest candidates name unprompted is what persistent connections do to your backend. Plain request/response HTTP is stateless — any server can handle any request, so you scale by adding boxes behind a load balancer. The moment you hold connections open (WebSockets or SSE), each user is pinned to a specific server for the life of the connection, and your service becomes a stateful connection fleet:

  • Sticky sessions / a connection registry. A message for user X has to reach the exact server holding X's socket, so you need to know where every connection lives — a registry mapping users to servers, and load balancers that keep a user on their server.
  • The pub/sub fan-out problem. When an event needs to reach many users whose connections are spread across many servers, you publish it to a message bus (Redis pub/sub, Kafka) and each server pushes to the sockets it owns. Routing and fan-out become their own subsystem.
  • Connection limits and failover. Each server holds a finite number of open sockets, and when one restarts every client on it must reconnect at once — so you plan for reconnect storms, backpressure, and graceful draining.

The point to state plainly: persistent connections move you off stateless HTTP — now a user is tied to one server, so you need a connection registry, sticky routing, and a pub/sub layer to fan messages out across the fleet, and you have to survive reconnect storms when a server dies. That scaling story — not the handshake — is where a real-time design is won or lost, and it is why you do not reach for WebSockets unless the feature truly needs them.

How to talk about real-time transports in an interview

The probes from every section rhyme. Master these five and you can defend a transport choice in any real-time design, not just this checklist.

  • "Why not just poll the server?" → HTTP is request/response, so the server can't push; short polling fakes it on a timer but trades waste against lag — long polling, SSE, or WebSockets give real-time without that. (problem solving)
  • "Long polling vs WebSockets — when each?" → Long polling holds one HTTP request open per message (near-real-time, no new infra, but connection churn); WebSockets keep one full-duplex TCP connection for constant two-way traffic. Long polling for rare updates or fixed infra, WebSockets for interactive. (communication)
  • "WebSockets or SSE for this?" → If data flows only server→client (a feed), SSE — one-way, HTTP-native, auto-reconnect; if both sides push (chat, games), WebSockets — full-duplex, low overhead. (technical execution)
  • "Your feature only pushes down — did you need WebSockets?" → No; one-way means SSE, which is lighter and rides on HTTP. WebSockets would be over-building and add stateful-connection cost for nothing. (problem solving)
  • "A million open WebSocket connections — how do you scale that?" → It's a stateful fleet: sticky routing, a connection registry mapping users to servers, a pub/sub bus to fan messages out, and a plan for reconnect storms when a server restarts. (technical execution)

Each maps to a debrief dimension. Reading them teaches the answers; it does not teach you to deliver them while someone fails your transport choice on the direction of data — that only comes from saying them out loud.

How to prepare: a short plan

You do not need a new topic for every design. You need the transport vocabulary automatic, so when a design needs real-time delivery you reach for the right one without defaulting to the heaviest.

  • Day 1: Learn why HTTP can't push and climb the ladder — short polling, long polling, SSE, WebSockets — until you can draw each connection pattern from memory.
  • Day 2: Drill the two comparisons — long polling vs WebSockets and WebSockets vs SSE — on direction (one-way vs full-duplex), overhead, and infra cost. These are where the follow-ups live.
  • Day 3: Place a transport inside a real design (a chat app, a notification feed, a live dashboard): pick one off the data direction, justify it, and name the stateful-connection scaling cost. Then do it out loud, timed, with someone asking "did you need WebSockets at all?"

This explainer feeds the broader Top 25 system design interview questions — real-time transports show up in chat, feeds, presence, and live dashboards, so getting the decision automatic pays off across the whole list.

Frequently asked questions

What is the difference between long polling, WebSockets, and SSE?

They are three ways to deliver real-time data when plain HTTP request/response can't, and they differ in how the connection is held and which direction data flows. Long polling stays entirely within HTTP: the client sends a request and the server holds it open until it has data, then responds, and the client immediately re-requests — so each message is still a separate request/response cycle with its own overhead. Server-Sent Events (SSE) keep a single long-lived HTTP connection open and the server streams a one-way sequence of text events down it, with the browser auto-reconnecting. WebSockets upgrade the HTTP connection to a single persistent TCP connection that is full-duplex, so both the client and server can send independently at any time with low per-message overhead and binary or text payloads. In short: long polling is request-per-message over HTTP, SSE is one-way server push over HTTP, and WebSockets are two-way push over a dedicated connection.

When should I use SSE instead of WebSockets?

Use SSE when data only ever flows from the server to the client — notification feeds, live scores, stock tickers, activity streams, or long-running progress updates. SSE is the lighter choice: it runs over ordinary HTTP so it passes through most proxies and firewalls, the browser's EventSource reconnects automatically and can resume from the last event id, and you don't take on the stateful-connection infrastructure a WebSocket fleet needs. Choose WebSockets only when the client also needs to push frequently and with low latency — chat, multiplayer games, collaborative editing. The common mistake interviewers probe is reaching for WebSockets on a one-directional feed, where SSE does the same job with less cost. The main caveats for SSE are that it is text-only and that browsers cap concurrent connections per domain, which matters at scale (less so over HTTP/2).

Is long polling still worth using over WebSockets?

Yes, in specific cases. Long polling delivers near-real-time updates while needing no special protocol — it works over plain HTTP through every proxy, firewall, and legacy browser — so it is the right call when you cannot change the infrastructure to support persistent connections, or when updates are infrequent enough that the connection churn doesn't matter. Its weakness is exactly that churn: every delivered message is a full request/response cycle with a new connection setup and a fresh round of headers and auth, so under a high, constant message rate it degrades toward the overhead of short polling and a burst of messages can trigger a thundering herd of re-requests. WebSockets win when traffic is frequent and bidirectional because one persistent connection carries many low-overhead messages both ways. So long polling is a pragmatic fallback, not a default.

Why can't plain HTTP handle real-time updates?

Because HTTP is a request/response protocol: the client opens a connection, sends a request, the server sends exactly one response, and the exchange closes. The server has no channel to initiate a message — it can only answer something the client asked. For real-time features the new information often originates on the server (a message arrived, a price changed, a user came online), and plain HTTP gives it no way to notify a client that isn't currently asking. Short polling works around this by having the client ask repeatedly on a timer, but that wastes requests on empty "nothing new" answers and still adds up to a full polling interval of lag. Long polling, SSE, and WebSockets each exist to give the server a real way to deliver data as soon as it exists, rather than waiting for the next client request.

How do I practise a system design interview out loud?

Reading about real-time transports is not the same as defending a transport choice while an interviewer pushes on the direction of your data and the cost of scaling it. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a design (like a chat app or a live notification feed) on a shared canvas, and a voice interviewer follows up one question at a time ("why not just poll?", "the data only flows down — did you need WebSockets?", "a million open connections, now what?"), then gives you a debrief on problem solving, communication, technical execution and time management. The score is a practice signal, not a hiring decision.

Practise it on Zynter

You can say "use WebSockets." The round is won on the data direction and the connection fleet.

Pick an HLD system design round with a real-time feature, lay out the transport on the canvas, and defend it out loud to a voice interviewer that keeps asking "why not just poll?" and "the data only flows server→client — did you need WebSockets at all?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).

Practise an HLD system design round →
Browse all interview tracks

Top comments (0)