Don't Mix Up Polling and Pooling
In system design, two similar-sounding terms often cause confusion: polling and pooling. They address completely different challenges — one deals with when to act, the other with how to manage resources.
Polling — Checking for New Data
Polling is when a consumer repeatedly checks if new data is available. The consumer tracks what it last saw (e.g., a timestamp or ID), then asks the producer:
“Is there anything newer than what I already have?”
If new data is available, the consumer then pulls it.
-
Polling vs. Pulling:
- Polling = "Do you have anything new?"
- Pulling = "Okay, now give me the new thing."
Push — The Opposite Approach
In a push model, the producer sends new data directly to consumers whenever it becomes available.
- Push is event‑driven rather than time‑driven, often implemented using consumer webhooks. As soon as new data is ready, the producer sends it to the consumer via an HTTP POST or PUT request
Pooling — Reusing Expensive Resources
Pooling refers to maintaining and reusing a fixed set of resources instead of creating new ones on demand. It is widely used for threads, database connections, or any object that is expensive to create and initialize.
-
Examples:
- Thread pool: Reuse a fixed number of threads.
- DB connection pool: Maintain live DB connections to avoid reconnecting.
Think of it as:
“Don’t create a new one — grab one from the pool.”
Summary
Term | Purpose | Example |
---|---|---|
Polling | Repeatedly check for updates | Checking job status, polling a queue |
Pulling | Retrieve data when needed | Fetching new messages or records |
Pushing | Send data as soon as it's ready | Webhook or POST from server to client |
Pooling | Reuse heavy resources | Thread pool, DB connection pool |
Happy coding! 💻