Technical Medium Frontend Backend Full Stack Software Engineer

Explain the differences between WebSockets, Server-Sent Events (SSE), and Long Polling.

Practise this question with AI feedback

Record your spoken answer or type your response to receive immediate scoring and STAR improvements.

💡 Suggested Approach & Sample Answer

Real-Time Transport Protocols:

1. WebSockets:
- Protocol: Full-duplex, bidirectional communication over a single persistent TCP connection, upgraded from an initial HTTP handshake (ws:// or wss://).
- Overhead: Minimal framing overhead (2-10 bytes per frame) after handshake; eliminates repeated HTTP headers.
- Best For: High-frequency bidirectional data exchanges: collaborative document editing, multiplayer gaming, financial trading terminals.

2. Server-Sent Events (SSE):
- Protocol: Unidirectional (server-to-client) streaming over standard HTTP (Content-Type: text/event-stream).
- Features: Built-in browser reconnection, event IDs, and custom event names over standard HTTP/2 multiplexing. Bypasses corporate firewall/proxy restrictions that block WebSockets.
- Best For: Real-time feeds where clients only consume updates: live sports scores, stock price tickers, AI streaming completions.

3. HTTP Long Polling:
- Protocol: Client opens an HTTP request that the server holds open until data arrives or times out, immediately re-requesting upon reply.
- Overhead: High latency and redundant HTTP header overhead on every message.
- Best For: Legacy fallback environments where WebSockets or SSE are blocked.

🎯 What Interviewers Listen For

How would you answer this in a real interview?

Use our free AI mock practice tool to test your response, analyze speaking pacing, and refine your STAR structure.

🔗 Related Technical Questions