Server sent events are the cheapest option when traffic flows server to client only: plain HTTP, automatic reconnect, and they pass through most proxies. WebSockets justify the operational cost when you need bidirectional or high frequency messaging, like chat or collaborative editing. Polling is fine when updates are rare and a few seconds of staleness is acceptable, and it survives every network and load balancer in existence.
Why interviewers ask this
Real time is where developers reach for the most complex option first. The interviewer wants to see you match the transport to the actual traffic pattern and think about what happens at scale: sticky connections, horizontal scaling, reconnection, and missed messages while a client was offline. Choosing polling for the right reason is a strong signal, because it shows you weigh operational cost rather than chasing the impressive answer.
How to structure your answer
- Match each option to the traffic direction and frequency it suits.
- Name the operational cost of persistent connections.
- Cover reconnection and missed messages.
- Recommend one for the scenario you were given.
Example answer
The first question is whether the client needs to send anything back over the same channel. Notifications, live counters, a job progress bar, a feed: all one way, and server sent events handle that over ordinary HTTP with built in reconnect and a last event id header so you can resume from where the client dropped. That last part is underrated. WebSockets are the right call for chat, presence, or anything collaborative where clients push frequently and latency matters. The cost is real though: connections are stateful, so scaling past one instance means a pub sub layer like Redis to fan messages across nodes, plus health checks, backpressure and auth on the initial handshake. And polling is not a joke answer. On an admin dashboard I built, updates mattered maybe once a minute, so a poll on window focus with an ETag was about fifteen lines of code, cost nothing to operate, and never woke anyone up at night. I would rather spend the complexity budget where users actually feel it.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How would you scale WebSocket connections across multiple servers?
- How do you deliver messages a client missed while disconnected?
- How do you authenticate and authorize a socket connection?
Related full stack developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions