What is polling? Short polling, long polling and push
How a client finds out that something changed on the server: by asking again and again (polling), by asking and waiting (long polling), or by keeping a connection open and letting the server push.
In one sentence
Polling means the client keeps asking the server "anything new?" on a timer. It's the simplest way to get updates, and also the most wasteful.
The problem: HTTP only answers questions
HTTP is request → response. The server can't call the browser out of the blue. So when you build a chat, a notification bell, a delivery tracker or a dashboard, you need a way for the client to learn that something changed on the server.
There are three classic answers. Play with them below: switch the strategy and watch how many requests go out, how many come back empty, and how long new data waits before the user sees it.
Short polling: ask every N seconds
The client sends GET /messages?since=… every few seconds. The server answers immediately, usually with nothing new.
setInterval(async () => {
const res = await fetch(`/api/messages?since=${lastId}`);
render(await res.json());
}, 3000);Pros
- Trivial to build: it's a normal endpoint
- Works everywhere, through any proxy or firewall
- Easy to cache and scale like any other GET
Cons
- Most requests are wasted work for client and server
- Updates arrive up to one interval late
- 1M users polling every 3 s = ~333K requests/s for mostly empty answers
The interval is a trade-off: shorter means fresher data and more load; longer means less load and staler data.
Long polling: ask, and let the server wait
The client sends a request and the server doesn't answer until there is something new (or a timeout of ~20–30 s passes). As soon as the client gets a response, it opens the next request.
- Data arrives almost instantly
- Far fewer empty responses
- Still plain HTTP, so it works where WebSockets are blocked
- But each waiting client holds an open connection on the server: you need a server stack that handles many idle connections cheaply (Node.js, Go, async frameworks)
Push: WebSockets and Server-Sent Events
Instead of asking, the client opens one long-lived connection and the server sends data the moment it exists.
| Technology | Direction | Good for |
|---|---|---|
| WebSocket | Both ways | Chats, multiplayer, collaborative editing |
| Server-Sent Events (SSE) | Server → client | Notifications, live scores, streaming AI responses |
| Mobile push (APNs / FCM) | Server → device | Reaching apps that are closed |
Which one should you use?
| Situation | Pick |
|---|---|
| Updates every few minutes, staleness is fine (a report status, a nightly import) | Short polling with a long interval |
| Near real-time, moderate scale, simple infrastructure | Long polling or SSE |
| True real-time, two-way, lots of messages (chat, games) | WebSockets |
| A job that takes minutes (video upload processing) | Poll a status endpoint, or notify with a webhook / push |
In a system design interview, a good answer often starts with short polling, explains why it doesn't scale, and moves to push for the parts that really need it. YouTube can poll for a video's processing status; a chat like WhatsApp keeps a persistent connection.
Key takeaways
- 01Polling = the client asks on a timer. Simple, but most requests come back empty.
- 02Long polling keeps the request open until there is data: faster and less wasteful, but holds connections.
- 03WebSockets and SSE keep one connection open and the server pushes: best for real-time.
- 04Choose by how fresh the data must be and how many clients you have.
Check your understanding
1 of 3
What is the main drawback of short polling?
Related concepts
SQS vs SNS
SQS stores messages until one consumer pulls and processes each of them; SNS pushes each message to every subscriber immediately and doesn't store it.
8 min read →Load balancers
A load balancer is the single entry point that receives every request and forwards it to one of many healthy servers, so no single server is overloaded and failures stay invisible to users.
8 min read →