Push vs Pull Backpressure Lab (Interactive)
Outrun the consumer threefold and watch push OOM the heap while Kafka lag banks the surplus safely. Compare server-initiated push, consumer-initiated pull, and hybrid ping-and-payload delivery under producer spikes, measuring buffer growth, lag, latency, and lost events.
Push vs Pull Delivery & Backpressure
Out-run your consumer by 3x and watch push crash heaps while pull banks lag in the log.
How It Works Under the Hood
Delivery direction decides who owns flow control. Push systems like WebSockets and RabbitMQ dispatch instantly, giving sub-5 ms latency, but when a producer at 100K events/s meets a consumer at 10K, socket buffers and heaps saturate until the worker crashes and in-flight messages are lost. Pull systems like Kafka invert control: consumers poll fixed batches at their own pace, so surplus traffic accumulates durably as lag in the partition log. Hybrid architectures push a 200-byte wake signal and pull heavy payloads from a CDN on demand.
Core Architectural Principles
- Pull consumers self-pace with poll(max_records), yielding natural backpressure and zero OOM.
- Push requires explicit credit-based flow control or the consumer buffer becomes the outage.
- Hybrid pushes metadata instantly and defers bandwidth-heavy payload fetches to the client.
Frame the choice by workload: push at the user edge for chat, gaming, and trading UIs where milliseconds are the product; pull in backend pipelines where durability and batching dominate, and explain Kafka deliberately chose pull for consumer-controlled flow. Finish with the hybrid pattern for mobile media, showing you can reason about battery, egress, and buffer limits together.
Push buys instant delivery with stateful connections; pull buys stability and batching at the cost of polling latency.