🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Design Back Pressure

ArchitectureResilience Patterns🟢 Free Lesson

Advertisement

Architecture

Design Back Pressure

Back pressure propagates overload signals upstream to prevent cascading failures. When a downstream service is overloaded, upstream services reduce their request rate rather than overwhelming the system.

  • Problem — Overload causes cascading failures
  • Solution — Signal propagation to reduce load
  • Goal — System operates at sustainable throughput

Back pressure is the immune system of distributed architectures: it detects overload and triggers protective responses.

What Is Back Pressure?

DfBack Pressure

Back pressure is a feedback mechanism where a downstream component signals an upstream component to reduce its request rate. This prevents queue buildup, memory exhaustion, and eventual system collapse. Back pressure can be explicit (HTTP 429, 503) or implicit (queue full, slow consumer).

Without back pressure, a system under load will: (1) Build unbounded queues, (2) Exhaust memory, (3) Start dropping requests, (4) Cascade failures to dependent services. Back pressure is the circuit breaker's companion.

Back Pressure Mechanisms

ProducerQueueConsumerDownstreamBack Pressure Signal

Strategies

1. Queue-Based Back Pressure

Queue Threshold

if queue.length>threshold:reject or slow producer\text{if } \text{queue.length} > \text{threshold}: \text{reject or slow producer}

Here,

  • thresholdthreshold=Maximum queue capacity
  • queue.lengthqueue.length=Current queue depth

2. Rate Limiting

DfToken Bucket Rate Limiting

Tokens are added to a bucket at a fixed rate. Each request consumes one token. If no tokens are available, the request is rejected. This smooths traffic bursts while allowing sustained throughput.

Token Bucket

tokens=min(capacity,tokens+rate×Δt)\text{tokens} = \min(\text{capacity}, \text{tokens} + \text{rate} \times \Delta t)

Here,

  • capacitycapacity=Maximum tokens (burst size)
  • raterate=Tokens per second (sustained rate)

3. Adaptive Load Shedding

Adaptive load shedding drops requests when system health degrades. Metrics like CPU, memory, latency, and error rate trigger shedding. Priority-based shedding protects critical paths.

4. Timeout-Based Back Pressure

Timeout Propagation

if latency>timeout:fail fast and signal upstream\text{if } \text{latency} > \text{timeout}: \text{fail fast and signal upstream}

Here,

  • timeouttimeout=Maximum acceptable latency
  • latencylatency=Observed response time

Health Check Signals

SignalThresholdAction
CPU > 80%HighReduce request rate
Memory > 85%CriticalShed load aggressively
Latency P99 > 500msWarningQueue and slow down
Error rate > 5%CriticalCircuit breaker open

Reactive Streams

DfReactive Streams (Back Pressure Protocol)

Reactive Streams define a standard for asynchronous stream processing with back pressure. The subscriber tells the publisher how many elements it can handle via request(n). This prevents the publisher from overwhelming the subscriber.

Practice Exercises

  1. Design: Implement back pressure for a microservice with 3 downstream dependencies at different capacities.
  2. Monitoring: Design a health check system that detects overload in < 5 seconds.
  3. Priority: Design priority-based load shedding where payment requests are never shed.
  4. Recovery: How do you gracefully resume normal load after back pressure is triggered?

Key Takeaways:

  • Back pressure propagates overload signals upstream to prevent cascading failures
  • Strategies: queue thresholds, rate limiting, adaptive shedding, timeout propagation
  • Token bucket provides smooth rate limiting with burst allowance
  • Reactive Streams define a standard for back pressure in async systems
  • Health metrics (CPU, memory, latency) drive adaptive back pressure decisions

What to Learn Next

-> Circuit Breaker Preventing cascade failures.

-> Retry Patterns Resilient retry mechanisms.

-> Idempotency Handling duplicate requests.

-> Saga Pattern Distributed transactions.

-> Load Balancing Distribution algorithms.

-> Design Netflix Resilient microservices.

Premium Content

Design Back Pressure

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
💼Interview Prep
📜Certificates
🤝Community Access

Already a member? Log in

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement