Go from "asking every few seconds whether there is a new message" to "the server tells you directly when there is one".
Why use it
Chat, order-status updates, collaborative editing, live dashboards, and AI token-by-token output all need the server to “push”. HTTP is request-response by nature, so you need one of these techniques.
How to do it
Technique
Direction
Traits
Best for
Short polling
Client asks repeatedly
Simplest, most wasteful
Low frequency, delay-tolerant
Long polling
Client asks; server answers only when there is a message
Best compatibility
Fallback when nothing else works
SSE
Server pushes one way
Plain HTTP; browsers reconnect automatically
Notifications, progress, AI streaming
WebSocket
Bidirectional
Low latency, full-featured
Chat, games, collaborative editing
Rule of thumb: server push only → prefer SSE first; high-frequency bidirectional interaction → WebSocket.
🧭 Which real-time technique to pick
Do you need the server to push?
NoTimed refresh (short polling) is enough
↓
Server → client only?
YesUse SSE
↓
Need high-frequency bidirectional interactionChat, games, collaborative editing
↓
Use WebSocket
🔀 Multiple servers: forward messages over a Redis backplane
User A
Server 1
Redis
Server 2
User B
1Send a message
2Publish to the backplane
3Broadcast to every machine
4Push to B
Component comparison
No component data for this language yet. On the home page choose "Decide later" and let AI recommend one.
SignalR
Built into the frameworkOpsLow
A .NET real-time communication library that lets the server push messages to browsers proactively, and automatically falls back and retries when a connection method fails.
Best forChat, notifications and live dashboards in .NET projects.
Avoid whenThe backend is not .NET, or you need interoperability with third parties over standard WebSocket.
Pros
It can automatically pick an available transport, such as WebSocket
Groups, broadcast, and per-user push are all built in
Reconnection after a disconnect has ready-made support
Cons
It fits .NET only, so Python projects cannot use it
Multiple servers need a separate Redis to sync messages
The protocol is its own, so ordinary clients cannot connect
The browser and server establish a long-lived two-way channel, and either side can send messages at any time.
Best forFeatures that need two-way, high-frequency real-time interaction.
Avoid whenThe server only occasionally pushes a notification to the page; SSE is simpler.
Pros
Two-way real-time, suited to chat, collaborative editing and online games
A standard protocol supported by almost every language and browser
Low latency and small overhead once the connection is established
Cons
Reconnection and heartbeat detection must be written yourself
Connections hold server resources continuously, so capacity must be planned for many users
Some proxies and firewalls need special configuration to let it through
SSE (Server-Sent Events)
Self-hosted open sourceOpen sourceOpsLow
The browser keeps one connection open and the server can keep pushing messages into it, but only from server to browser.
Best forScenarios where "the server only needs to push out", such as notifications, task progress and streaming AI replies.
Avoid whenYou need two-way high-frequency interaction (such as chat rooms or collaborative editing).
Pros
It uses ordinary HTTP, so proxies and firewalls usually allow it
The browser reconnects automatically after a disconnect
Simple to build, and a good fit for notices, progress, and character-by-character output
Cons
The server can only push downward; sending upward still needs a normal request
Proxies buffer output by default, and that must be turned off for live updates
Under HTTP/1.1 the number of connections per domain is limited
Long polling
Hand-rolledOpen sourceOpsMedium
After the browser sends a request, the server holds off replying until there is a new message, and the browser immediately sends the next request once it receives one.
Best forScenarios with few users, low real-time requirements, or network environments that restrict other methods.
Avoid whenLarge user counts, or when you need genuinely low-latency real-time interaction.
Pros
Uses only ordinary HTTP requests, so compatibility is the best and it runs in any environment
Simple to reason about, needing no special protocol
A reliable fallback when WebSocket cannot be used
Cons
Every message requires a new request, so overhead is higher than WebSocket
The server must hold many waiting requests at once, which strains it with many users
Message timeliness and ordering must be handled yourself, making missed or duplicate messages likely
Socket.IO
Open-source libraryOpen sourceOpsLow
The most widely used real-time communication library on Node.js, adding rooms, broadcasting, automatic reconnection, and fallback transports on top of WebSocket.
Best forNode projects such as chat, collaboration, and real-time notifications that need rooms and broadcasting.
Avoid whenYou only need one-way push (SSE is simpler), or you need standard WebSocket interoperability with third-party clients.
Pros
Rooms, namespaces, broadcasting, and more work out of the box
Built-in automatic reconnection and acknowledgements
Integrates with NestJS (@nestjs/websockets), Express, and Fastify
Cons
It has its own protocol, so clients must use the Socket.IO client library
Multi-instance deployment needs an adapter such as Redis for broadcasting
Connection authentication and per-message permission checks are yours to implement