Skip to the content.

Short Polling

What it is:

Client makes a request again and again at a fixed interval (every 2 sec, 5 sec, etc.) to check if new data is available.

How it works (simple):

Client → Server: Any update?
Server → Client: No

Client → Server (after 2 sec): Any update?
Server → Client: No

Client → Server (after 2 sec): Any update?
Server → Client: Yes! Here is data.

Pros

Cons

Easy explanation:

🟦 “Knocking the door repeatedly every few seconds even if nothing changed.”


Long Polling

What it is:

Client sends a request once, and server holds the connection open until new data is available.

How it works (simple):

Client → Server: Any update?
Server: (waiting...)  
Server: (data available!) → sends response
Client → Immediately sends another long poll request

Pros

Cons

Easy explanation:

🟩 “You knock once and wait at the door until something happens.”


⭐ Short Polling vs Long Polling — Summary Table

Feature Short Polling Long Polling
Request Frequency Fixed intervals (e.g., every 5 sec) Only when needed
Connection Close immediately Stays open until data arrives
Server Load High Medium
Data Freshness Slower Near real-time
Complexity Easy Moderate
Use Cases Simple status checks Chat apps, notifications

🎯 When to use what?

✔ Use Short Polling when:


✔ Use Long Polling when:

Used in:


⭐ Ultra Simple Analogy

Short Polling:

You call your friend every 5 minutes: “Did the parcel arrive?”

Long Polling:

You call once and stay on the line until he says: “It arrived!”