Course contentsShow
← System Design
Lesson 1680 of 1,91940. Real-World System: Social Media FeedFree lesson

Backpressure and Rate Limiting Updates

Handling bursts of activity by throttling update delivery to prevent overwhelming clients and network connections.

Backpressure and Rate Limiting Updates

You'll learn how to protect clients and servers from being overwhelmed during traffic spikes in real-time social feeds.

When a celebrity posts or a viral event occurs, thousands of updates might flood toward connected users simultaneously. Without protection, this tsunami of data can crash mobile apps, exhaust server resources, and degrade the entire user experience.

The Problem

Real-time systems using WebSocket or SSE connections face a fundamental challenge: clients connect at varying speeds (mobile vs WiFi), and servers can produce updates faster than clients can consume them. If you push every update immediately to every connected user, slow clients become bottlenecks, and network buffers overflow.

Backpressure: Let the Client Control the Flow

Backpressure means respecting the client's consumption rate. If a client can't keep up, the server must either:

  • Queue updates temporarily (with a size limit)
  • Drop less important updates
  • Slow down the sending rate

Think of it like a water pipe: if the exit is narrow, you can't force more water through without causing a backup.

Rate Limiting: Server-Side Protection

Rate limiting caps how many updates any single connection receives per time window:

Max: 100 updates per user per minute
If exceeded: batch remaining updates or defer to next fetch

This prevents a single high-activity user from consuming disproportionate resources. When limits hit, you can:

  • Collapse multiple updates into summaries ("5 new posts")
  • Switch from push to pull for that user temporarily
  • Prioritize high-value updates (direct mentions over generic timeline posts)

Implementation Strategy

Combine both: monitor each connection's send buffer size (backpressure signal) and enforce per-connection rate limits. When thresholds breach, gracefully degrade to batched or polling-based updates.

Key Takeaway: Backpressure and rate limiting protect both clients and servers from burst overload by controlling update flow rates and respecting consumption capacity.