What is the difference between push and pull architectures?

Answer

Push architecture: the server/producer actively sends data to clients/consumers when new data is available. The server initiates the communication. Examples: WebSockets, server-sent events (SSE), webhooks, Kafka push to consumers. Pros: low latency (data delivered immediately when available), no polling overhead, real-time. Cons: server must maintain connections, can overwhelm slow consumers (need back-pressure), requires persistent connection (WebSockets) or pre-registered endpoint (webhooks). Pull architecture: the client/consumer periodically requests data from the server/producer. The consumer initiates the communication. Examples: REST API polling, Kafka consumer pulling from topic, database queries. Pros: consumer controls its processing rate (natural back-pressure), simpler server (stateless), works across firewalls/NAT. Cons: inherent latency (must wait for next poll), wasted requests when no new data (polling overhead). Long polling: hybrid — client sends a request, server holds it open until new data is available, then responds. Lower latency than short polling. When to use each: push when real-time delivery matters and connections are manageable (chat, notifications, live feeds); pull when consumers have varying processing speeds and connection management is complex (batch processing, ETL, Kafka consumers). Most systems use both patterns in different parts of the architecture.