Free preview

Message Extraction: Pull versus Push

Why this matters: the requirements say consumers "retrieve messages." That verb hides a real design decision — does the consumer ask, or does the broker send? The answer determines who controls the rate, and rate control is what keeps the system from collapsing.

Key takeaway

Two models. In pull, the consumer requests messages when it is ready. In push, the broker delivers as soon as messages arrive. The difference is who decides the delivery rate — and that decides who absorbs an overload.

The two models

PullPush
Who initiatesThe consumer, when it has capacityThe broker, when a message arrives
Rate is controlled byThe consumerThe producer, indirectly
Latency when idleUp to one poll intervalImmediate
Cost when idleWasted empty pollsNone
Behavior under overloadConsumer simply asks for less; backlog stays in the queueBroker overwhelms the consumer unless flow control is added
BatchingNatural — ask for 100 at a timeRequires explicit support
Consumer must beNothing special — can sit behind a firewall or NATAddressable by the broker

Pull, and the polling problem

The naive pull implementation is short polling: the consumer asks repeatedly on a fixed interval.

Consumer:  any messages?  -> no
           (wait 1s)
           any messages?  -> no
           (wait 1s)
           any messages?  -> yes, here are 3

This trades two bad properties against each other with one dial:

  • Short interval → low latency, but most polls return empty — wasted requests, wasted broker CPU, wasted money on a metered service.
  • Long interval → few wasted polls, but a message can sit up to one full interval before anyone looks at it.

Long polling removes the trade almost entirely. The consumer's request blocks at the broker until either a message arrives or a timeout expires:

Consumer:  any messages? (I'll wait up to 20s)
Broker:    ...holds the connection...
           message arrives -> returns immediately

Why push is harder than it looks

Push sounds strictly better — no polling, no wasted requests, immediate delivery. The problem shows up under load.

What real systems chose

SystemModelNotes
Apache KafkaPullConsumers fetch batches at their own pace and track their own offset. The design document explicitly argues that pull avoids overwhelming consumers and makes batching natural
Amazon SQSPullReceiveMessage with long polling up to 20 seconds
RabbitMQPush (with pull available)Delivers to subscribed consumers, bounded by a prefetch count for flow control. A basic.get pull API exists but is discouraged for throughput

Choosing

ChooseWhen
Pull with long pollingThe default. High throughput, variable consumer speed, consumers that autoscale, or many consumers. You get flow control and batching for free
PushLow, predictable message rates where latency matters more than throughput, consumers are few and stable, and you are willing to configure prefetch limits
Push to an endpoint (webhooks, SQS→Lambda)The consumer is serverless or event-triggered and has no process sitting there to poll. The platform absorbs the flow-control problem for you

Key takeaway

Pull with long polling is the default for good reason: the consumer keeps control of the rate, batching is natural, and push's latency advantage largely disappears. Push needs explicit flow control — which is pull, reimplemented — and forces the broker to hold per-consumer state.

Interview signal by level

LevelWhat a strong answer sounds like
L4"Consumers read messages off the queue."
L5Names the models and picks one: "pull, with long polling so we're not burning requests on empty responses but still get near-immediate delivery."
Staff+Argues from backpressure: "pull, because the consumer controls the rate — under push an overload relocates the backlog into the consumer, which has no durability. Push needs prefetch limits, and a prefetch limit is just pull reimplemented. Pull also batches naturally, which matters more than it sounds: per-message overhead dominates when the work per message is small."

Next: the architecture.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue