Site icon Being Software Craftsman (DFTBA)

Polling Is Not the Problem—Bad Polling Is

Polling often gets a bad reputation in modern system design. With WebSockets, Server-Sent Events, and message queues becoming mainstream, polling is sometimes labelled as old-school.
The reality, however, is far more balanced.

Polling remains one of the most reliable and practical communication patterns—when used correctly.

As a software craftsman and architect, I’ve seen many systems struggle not because they chose polling, but because they implemented it without discipline.

Let’s break this down clearly.


What Is Polling?

Polling is a communication pattern where a client periodically asks the server:

“Has anything changed since the last time I checked?”

Instead of the server pushing updates to the client, the client pulls information at regular intervals using standard HTTP requests.


Common Use Cases for Polling

Polling works best when near-real-time updates are not mandatory.

Typical scenarios include:

In these situations, simplicity and predictability matter more than millisecond-level latency.


Why Polling Still Works

Polling continues to exist because it solves real problems well.

It:

From an architectural perspective, polling deliberately trades efficiency for reliability, transparency, and operational ease.


Pros of Polling

Simplicity

No persistent connections. No complex state management.
Just request, response, and repeat.

Predictable Load

Fixed or adaptive intervals make traffic patterns easy to estimate, monitor, and scale.

Firewall and Network Friendly

Unlike WebSockets or long-lived connections, polling rarely breaks in restricted or corporate networks.

Easy to Monitor and Debug

Standard HTTP logs, metrics, retries, and alerts apply naturally without specialised tooling.


Cons of Polling

Wasted Requests

Most polling requests return “no change”, especially as systems scale.

Increased Latency

Updates are visible only after the next poll interval.

Backend Pressure at Scale

Large numbers of clients polling blindly can overload backend services.

Poor User Experience If Misused

Aggressive polling can drain battery and network resources, particularly on mobile devices.

Polling is not bad. Blind polling is.


Effective Ways to Implement Polling (The Right Way)

1. Poll Only When Needed

Polling should be contextual, not continuous.

Best practices:

This alone can reduce unnecessary traffic by a significant margin.


2. Use Adaptive Intervals (Avoid Fixed Timers)

Polling every 1–2 seconds indefinitely is rarely justified.

A more responsible strategy:

This balances user responsiveness with backend stability.


3. Use Conditional Requests

Let HTTP do the heavy lifting.

Leverage:

If nothing has changed, the server responds with 304 Not Modified, which means:

This is one of the most effective optimisations for polling-based systems.


4. Respect Server Hints

A well-designed backend should actively guide the client on when to poll next, instead of forcing the frontend to guess.

Example response:

{
  "status": "IN_PROGRESS",
  "nextPollAfter": 10000
}

Here, the backend explicitly communicates the recommended delay (in milliseconds) before the next poll.

When the frontend respects nextPollAfter:

This pattern is especially valuable in large-scale distributed systems, where backend pressure must be managed centrally.


5. Backoff on Errors

Polling must be resilient to failure.

Aggressive retries during outages often cause cascading failures across systems. A disciplined retry strategy is essential.

Best practices:

The goal is to reduce pressure on an already struggling system, not amplify it.


6. Centralise Polling Logic

One of the most common mistakes in frontend applications is allowing each UI component to poll independently.

This leads to:

A better approach is to centralise polling:

This ensures:

Closing Thoughts

Polling is often underestimated because it looks simple.
Effective polling is not about how frequently you ask the server.
It is about when to ask, when to wait, and when to stop.

When combined with:

Polling becomes a responsible, scalable, and production-grade communication pattern—even in modern distributed systems.

Exit mobile version