Course contentsShow
← System Design
Lesson 649 of 1,91918. Message Queues and BrokersFree lesson

Load Smoothing and Backpressure

Using queues to absorb traffic spikes and prevent overwhelming downstream services with too many requests.

Load Smoothing and Backpressure

What You'll Learn

How message queues absorb traffic spikes and protect downstream services from being overwhelmed by too many requests.


The Problem: Spiky Traffic

In distributed systems, traffic rarely arrives at a constant rate. You might get 100 requests per second normally, then suddenly 10,000 requests during a flash sale or viral event. If all those requests hit your backend services immediately, they'll likely crash or become unresponsive.

Load Smoothing: The Buffer Zone

Load smoothing means using a message queue as a buffer between producers (incoming requests) and consumers (processing services). Instead of requests directly hitting your database or business logic, they enter a queue first.

Think of it like a restaurant's waiting area. When 50 customers arrive at once, they don't all crowd into the kitchen — they wait in line, and the kitchen serves them at a pace it can handle.

The queue holds excess messages during spikes and releases them steadily to consumers, "smoothing" the irregular load into a manageable stream.

Backpressure: Knowing When to Slow Down

Backpressure occurs when the queue communicates back to producers: "I'm getting full — slow down!" This prevents the queue itself from overflowing and losing messages.

Common backpressure strategies:

  • Return errors to producers when queue depth exceeds a threshold
  • Apply rate limiting at the producer side
  • Block producers temporarily until space becomes available

Without backpressure, a queue could grow infinitely, consuming all memory and eventually crashing.


Key Takeaway: Message queues smooth traffic spikes by buffering requests and releasing them at a sustainable rate, while backpressure mechanisms prevent the queue itself from being overwhelmed — protecting your entire system from cascading failures.