System design concepts · Communication

Push vs Pull

Short answer

In a push model the producer sends data to the consumer as soon as it is available. In a pull model the consumer asks the producer for data when it is ready to handle it. Push gives the lowest delivery latency and no wasted polling, but the producer has to know who the consumers are and can overwhelm a slow one. Pull lets each consumer set its own pace, makes retries and replay simple, and keeps the producer unaware of who reads, at the cost of polling delay or empty requests when nothing has changed. The same trade-off appears across system design: news feeds (fan-out on write versus fan-out on read), message brokers (RabbitMQ usually pushes to consumers, Kafka consumers pull), monitoring (Prometheus scrapes targets, other agents push), and client updates (webhooks and WebSockets versus polling).

Read the video transcript

Data has to get from a producer to a consumer. The real question is: who starts the transfer? With push, the producer sends the moment something happens. Delivery is immediate, and nobody wastes a request asking for nothing. But the producer has to track every consumer, and a slow one can get flooded. So push needs backpressure, like a prefetch limit. With pull, each consumer asks when it's ready. It sets its own pace, and if it goes offline, it resumes from its last position. The cost is delay, or empty polls when nothing has changed. News feeds use both. Fan-out on write pushes each new post into every follower's timeline, so reading is one lookup. But for an account with a huge following, one post becomes a huge number of writes. So the usual design is a hybrid. Push posts from ordinary accounts, pull posts from the very large ones at read time, and merge. The same choice shows up everywhere. Kafka consumers pull and track their own offsets. Webhooks and mobile notifications push.

Push vs Pull: comparison table

AspectPushPull
Who starts the transferThe producerThe consumer
Delivery latencyLowest: sent when producedDepends on the polling interval, or a long poll that waits
Flow controlProducer must respect consumer limits (prefetch, backpressure)Built in: the consumer only takes what it can handle
Producer knowledgeMust track subscribers and where to reach themDoes not need to know who reads
Wasted workMay deliver data nobody reads, such as feed entries for inactive usersEmpty polls when nothing changed
RecoveryRetries and buffering for offline consumersConsumer resumes from its last position
ExamplesWebhooks, mobile push, WebSockets, fan-out on write feedsKafka consumers, Prometheus scraping, REST polling, fan-out on read feeds

When to use each

Push when

  • Latency matters and updates are relatively rare compared with how often a consumer would poll.
  • The set of consumers is known and they can keep up.
  • The consumer cannot easily poll, such as a phone that is asleep or a third-party webhook endpoint.

Pull when

  • Consumers run at different speeds or go offline and need to catch up.
  • You want replay: reprocessing from an earlier position after a bug.
  • There are many producers and you do not want each of them to track consumers.
The verdict

Push when

Latency matters and updates are relatively rare compared with how often a consumer would poll.

Otherwise

Pull when

Consumers run at different speeds or go offline and need to catch up.

News feeds use both

Fan-out on write is push: when someone posts, the system writes the post ID into every follower's precomputed timeline, so reading a timeline is a single fast lookup. It breaks for accounts with huge followings, where one post means a huge number of writes, most of them for followers who will not open the app soon.

Fan-out on write for normal accounts, fan-out on read for celebrities.

Fan-out on read is pull: the timeline is assembled at read time from the accounts a user follows. The usual answer is a hybrid: push posts from ordinary accounts, and pull posts from very large accounts at read time and merge them in.

Brokers and monitoring

Kafka consumers pull batches from partitions and track their own offsets, which makes slow consumers safe and replay easy. RabbitMQ typically pushes messages to subscribed consumers, with a prefetch limit to stop a consumer being flooded. In monitoring, Prometheus pulls by scraping each target on an interval, which makes a dead target obvious, while push-based agents suit short-lived jobs that may finish before a scrape would reach them.

A Kafka consumer pulls and keeps its offset, and Prometheus scrapes every target.
Interview angle

How it comes up in a system design interview

The feed question is the classic, but the same reasoning comes up for notifications, webhooks, metrics and any queue. State which side initiates, why, and what you do about the weakness of the side you chose: backpressure for push, latency and wasted calls for pull.

Where you will meet it

  • Should a new tweet be written into followers' timelines at post time or assembled when they open the app?
  • How does a notification reach a phone that is offline, and what happens when it comes back?
  • Does the monitoring system scrape services or do services push metrics to it?
  • A webhook receiver is down for an hour. What does the sender do?
How a strong answer sounds
“I would use fan-out on write for most accounts so timeline reads are one lookup, and switch to fan-out on read for accounts above a follower threshold, merging their recent posts at read time. That bounds the write amplification from a single post while keeping reads fast for nearly everyone.”

Common mistakes

  • Picking pure fan-out on write for a feed and never addressing accounts with very large followings.
  • Pushing to consumers with no backpressure, so a slow consumer runs out of memory or drops messages.
  • Polling on a short fixed interval at large scale, which turns idle clients into steady load.

Frequently asked questions

Is Kafka push or pull?

Pull. Consumers fetch batches from the brokers and commit their own offsets. Fetch requests can wait on the broker for data to arrive, which keeps latency low without busy polling.

Is long polling push or pull?

It is pull that behaves like push. The client asks, and the server holds the request open until there is data, so updates arrive almost as soon as they exist.

Is a webhook push?

Yes. The producer calls the consumer's URL when an event happens. That makes retries, signing and handling a consumer that is down the producer's responsibility.

Learn and practise

Lessons

Problems where this choice matters

Knowing the trade-off is half of it

Practise saying it under follow-up questions: a timed system design interview with an AI interviewer that probes your choices and grades against a rubric.

Start a mock interview