categories.api-design Intermediate

WebSocket vs Long Polling vs SSE: Differences and Use Cases

AI Practice

Real-Time Communication Comparison

Short Polling

Client requests at fixed intervals (e.g., every 5s) ❌ High latency, many wasted requests, server load

Long Polling

Client sends request; server holds until new data is ready ✅ More real-time than short polling ❌ Connection must be re-established after each response

Server-Sent Events (SSE)

One-directional: server pushes to client over HTTP long connection ✅ Simple, auto-reconnect, HTTP-compatible ❌ One-way only; client cannot send over same connection

WebSocket

Bidirectional, full-duplex, persistent TCP connection ✅ Lowest latency, efficient for frequent two-way communication ❌ Requires special load balancer config (sticky session or pub/sub)

Decision Guide

Use Case Recommended
Chat, collaborative editing WebSocket
Notifications, live feed SSE
Simple infrequent polling Long Polling
Real-time market data WebSocket or SSE

Interview bonus: WebSocket horizontal scaling uses Redis Pub/Sub across nodes (e.g., Socket.io Redis Adapter).

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub