Long Polling
What Is Long Polling?
Long polling is an HTTP communication technique in which an app asks a server for updates and the server waits to reply until new data arrives or a timeout occurs. After receiving the response, the app sends a new request, creating a near-real-time update loop. It is not one permanently open connection. Each request eventually receives a response and closes.
How Long Polling Works
This pattern lets a notification feed respond soon after an event instead of checking on a fixed schedule.
- The client sends an HTTP request asking for updates.
- The server holds the request while no relevant update exists.
- When an event arrives, such as a completed job, the server returns the update.
- If no event arrives in time, the server returns an empty response or timeout result.
- The client closes the completed request and immediately starts another one.
Long Polling vs Short Polling, Server-Sent Events, and WebSockets
The best choice depends on how often updates occur and whether the client must also send live messages.
| Method | Request behavior | Best fit |
|---|---|---|
| Short polling | Requests repeat on a timer | Infrequent, non-urgent checks |
| Long polling | One request waits, then reconnects | Occasional server-to-client updates |
| Server-Sent Events | One-way streaming connection | Continuous feeds and live dashboards |
| WebSockets | Persistent two-way connection | Chat, collaboration, and interactive apps |
Benefits of Long Polling
Long polling remains useful because it builds on familiar web infrastructure.
- It works over standard HTTP/HTTPS and can suit restrictive networks.
- It creates fewer empty requests than short polling.
- It provides a practical fallback when WebSockets are unavailable.
- It fits intermittent alerts, status changes, and queue updates.
Limits and Scaling Challenges
Waiting requests shift work from repeated requests to connection management.
- Many held requests consume server, proxy, and load-balancer capacity.
- Different timeout settings can cause unexpected disconnects.
- Simultaneous reconnects can create traffic spikes.
- Clients must handle duplicate, missed, or out-of-order events.
When Should You Use Long Polling?
Use it when updates matter soon, but are not frequent enough to justify a permanent two-way channel.
- Choose it for legacy HTTP environments or WebSocket-restricted networks.
- Use it for low-frequency notifications and background job status.
- Prefer SSE for steady one-way streams.
- Prefer WebSockets for frequent, two-way interaction.
Reliable Long Polling Implementation Practices
Reliability depends more on reconnection behavior than on the waiting request itself.
- Set explicit client, server, and proxy timeout policies.
- Use exponential backoff with jitter after failures.
- Authenticate and authorize every request.
- Send event IDs so clients can resume after a disconnect.
- Make client updates idempotent, meaning a repeated event is safe.
- Monitor timeouts and test through real proxies and load balancers.
Long Polling in Apps Built With Emergent
When planning app design and development, choose long polling only when its update pattern fits the product. Emergent can help build full-stack endpoints, client retry behavior, and tests for notification or status flows, while teams can consult the software glossary for related concepts. Build responsive apps with Emergent.
on Emergent today


