Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Your product needs real-time updates to web and mobile clients. Compare SSE, WebSocket, long polling and push notifications as a platform standard.

SSE is a one-way server-to-client stream over ordinary HTTP: simple, friendly to proxies and HTTP/2, with automatic reconnection built in. WebSocket is bidirectional with very low overhead per message, but it is stateful and harder to run through proxies and to scale. Long polling works everywhere at the cost of more overhead and latency, and mobile apps in the background can only be reached through the operating system's push notifications. As a platform standard, we choose SSE for server push by default, WebSocket only where clients send frequent messages, OS push for background mobile, and provide shared fan-out infrastructure for all of them.

Why this question is asked

Real-time features arrive one at a time: a notification badge, a live order status, a chat, a collaborative editor. If each team picks its own technology, the company ends up running several connection stacks with different security reviews and client libraries. Interviewers ask this question to see whether we understand what each technology actually costs, not just which is newest. In this answer, we will recap the four options, compare them on the points that matter in operation, look at the special case of mobile apps, and then set a default with clear exceptions and a shared infrastructure behind it.

1A Quick Recap of the Four Options

Server-sent events, SSE, keep one HTTP response open and let the server write events into it as text. The browser's EventSource parses them and reconnects automatically, sending the last event id it saw. Communication is one way, from server to client; the client talks back with ordinary HTTP requests.

WebSocket starts as an HTTP request with an Upgrade header and then switches the TCP connection to a different protocol, in which both sides can send small framed messages at any time. It is a full duplex channel, meaning both directions at once, with only a few bytes of framing per message.

Long polling is a trick with plain requests: the client asks "anything new?", and the server holds the request open until there is an event or about 30 seconds pass, then answers. The client immediately asks again. Push notifications are different again: services run by Apple (APNs) and Google (Firebase Cloud Messaging) deliver small messages to a device even when our app is not running, and the operating system shows them or wakes the app.

2Comparing Them Where It Matters

The table below compares the options on the properties that drive operating cost and user experience.

Real-time options compared
PropertySSEWebSocketLong pollingOS push
Directionserver to clientboth waysserver to clientserver to device
Transportplain HTTP, HTTP/2upgraded TCPplain HTTPApple or Google service
Proxies, firewallsusually fineneed upgrade supportalways finenot our concern
Reconnectbuilt in, Last-Event-IDwrite it yourselfevery responsehandled by OS
Per-message costsmallsmallestfull request eachsmall payloads only
Works in backgroundnononoyes

3SSE: Simple Server Push

SSE's strength is that it is just HTTP. Authentication uses the same cookies or headers as other requests, load balancers and proxies treat it like a long response, HTTP/2 multiplexes many streams over one connection (removing the old limit of about six connections per host in HTTP/1.1), and reconnection with resume is in the browser already. In Spring it is an SseEmitter or a Flux<ServerSentEvent<T>>.

The costs are modest. Proxies must not buffer the response and must allow long idle periods, which heartbeat comments every 15 to 30 seconds handle. The data is text, so binary payloads need encoding. And the client cannot send over the same channel, which for most server-push features, notifications, status updates, live dashboards, is not a limitation at all.

4WebSocket: When Clients Talk a Lot

WebSocket earns its complexity when the client sends frequent messages: a chat with typing indicators, a multiplayer game, a collaborative editor sending keystrokes. Sending each of those as an HTTP request would add hundreds of bytes of headers and a request round trip; over a WebSocket, a message is a few bytes of framing.

But the connection is stateful in a way the rest of our HTTP stack is not. Every proxy and load balancer on the path must support the upgrade and long-lived connections; some corporate proxies do not. There is no built-in reconnection or resume, so clients need code for backoff and missed messages. Scaling means fan-out between instances, connection draining during deploys and protection against reconnect storms. Security reviews also differ, since authentication happens once at the handshake and message-level authorisation is ours to build. These are not reasons to avoid WebSocket, but they are reasons not to use it where SSE would do.

5Long Polling and Mobile Push

Long polling works through anything that passes HTTP, which made it the standard before SSE and WebSocket. Its cost is overhead: each event costs a full request and response with headers, and there is a small gap after each response before the next poll arrives. It remains useful as a fallback for unusual networks, but not as a default.

Mobile apps add a constraint none of the connection-based options can solve. When an app goes to the background, iOS and Android suspend it and its connections die within seconds to minutes. The only way to reach the user then is OS push through APNs or FCM. Push messages are small (a few kilobytes), delivery is not guaranteed and may be delayed, and the platform rules limit how they are used. So push is the wake-up signal, and the app fetches the real data over HTTP when it opens. While the app is in the foreground, it can use SSE like the web client.

6The Standard: Defaults, Exceptions and Shared Infrastructure

The platform standard follows from the comparison. SSE is the default for server push to web and foreground mobile clients. WebSocket is allowed when a feature's clients send frequent messages, and the team says so in its design review. OS push is used for reaching mobile users in the background, through one shared notification service. Long polling exists only as a fallback inside the client library.

Behind all of them sits shared infrastructure, so no team builds fan-out alone: connection gateways that hold SSE and WebSocket connections, a broker through which any service publishes events for a user or topic, a per-user history store for replay after reconnect, and one push service that holds the APNs and FCM credentials. Product services just publish events; the platform decides how they reach each client.

Step throughChoosing a channel for a new feature
  1. Must reach a backgrounded mobile app?
    YesOS push via the shared serviceNoConnection-based channel
  2. Do clients send frequent messages?chat, games, co-editing
    YesWebSocketNoSSE (default)
  3. Network blocks streaming?rare corporate proxies
    YesLong polling fallback in client libraryNoKeep chosen channel

3 steps in order. Play them, or step through them one at a time.

7Follow-up questions

Does SSE scale worse than WebSocket because it uses HTTP?

Not in a meaningful way. Both hold one long-lived connection per client, and with HTTP/2 SSE streams share connections. The scaling problems, memory per connection, fan-out between instances, reconnect storms, are the same for both. WebSocket's advantage is the client-to-server direction, not server-side scale.

Can we use only push notifications for mobile and skip SSE?

For background delivery, yes, but push is not a data channel: payloads are small, delivery can be delayed or dropped, and rate rules apply. A foreground app showing a live order status should use a stream for real-time updates and treat push as the way to bring the user back.

What would make you choose WebSocket for a notifications feature?

Only if the same feature needed frequent client messages, such as acknowledging each notification in real time or sending presence updates, and HTTP requests for them were measurably too expensive. Otherwise SSE plus ordinary requests for the occasional client action is simpler to run.

8Conclusion

In this answer, we compared four ways of delivering real-time updates. SSE is one-way push over plain HTTP with built-in reconnection and resume; WebSocket is bidirectional and efficient but stateful and harder to operate; long polling works everywhere with more overhead; and OS push is the only way to reach backgrounded mobile apps. The platform standard uses SSE by default, WebSocket only where clients send frequent messages, OS push for mobile background delivery, long polling as a fallback, and one shared fan-out infrastructure behind them.

What to say in the interviewAbout 90 seconds aloud

Open with

I would compare them on direction, operations and the clients we serve. SSE is server-to-client over ordinary HTTP: authentication, proxies and HTTP/2 just work, and the browser reconnects automatically with Last-Event-ID, so resume is easy.

Then, if they want more

WebSocket is bidirectional with tiny framing per message, which is great when clients send a lot, like chat or collaborative editing, but it is stateful: proxies must support the upgrade, reconnection and resume are our code, and scaling and deploys are harder.

Long polling works everywhere but costs a full request per event and adds small gaps, so I keep it as a fallback. And none of these reach a mobile app in the background, because the OS suspends it; there we need APNs and FCM push, which carries small, best-effort messages that wake the app so it fetches data.

So my standard would be: SSE as the default for server push to web and foreground mobile, WebSocket only when a feature's clients send frequent messages and it is justified in design review, OS push through one shared service for background mobile, and long polling only inside the client library as a fallback.

Most importantly, I would provide shared infrastructure: connection gateways, a broker for fan-out, a per-user replay store and a push service, so product teams publish events and never build this themselves.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your product needs real-time updates to web and mobile clients. Compare SSE, WebSocket...": https://scrivio-interview-library.netlify.app/spring-boot/web-other/a9d7480451/