Backpressure
TL;DR
Backpressure signals upstream producers to slow down when downstream consumers can't keep up — preventing queue overflow, memory exhaustion, and system collapse under load.
Explanation
Without backpressure: fast producer + slow consumer → queue grows indefinitely → OOM or unbounded latency. Backpressure strategies: (1) Block producer (synchronous — producer waits until consumer is ready). (2) Drop messages (circuit breaker — shed load). (3) Buffer with size limit (bounded queue — producer blocks or errors when full). (4) Rate limiting producer. (5) Signal via protocol (TCP flow control, Reactive Streams, gRPC flow control). In PHP: Redis list maxlength, queue bounded size, Swoole channel with capacity, HTTP 429 Too Many Requests. ReactiveX / RxPHP: Observable with backpressure operators.
Common Misconception
✗ Unlimited queue size is safer — an unbounded queue causes OOM and system collapse. A bounded queue with explicit backpressure is safer.
Why It Matters
Without backpressure, a slow consumer causes unbounded queue growth that takes down the entire system — backpressure is the feedback mechanism that keeps systems stable under load.
Common Mistakes
- Infinite queue — hides the problem until OOM.
- No backpressure to HTTP clients — API accepts more than it can process.
- Blocking the event loop with backpressure — use async/non-blocking where possible.
Code Examples
✗ Vulnerable
// Unbounded Redis list — can grow until OOM:
$redis->rpush('jobs', $job); // No limit
✓ Fixed
// Bounded with backpressure:
$len = $redis->llen('jobs');
if ($len >= 10000) {
throw new ServiceUnavailableException('Queue full — apply backpressure');
// HTTP 503 to caller — let them retry
}
$redis->rpush('jobs', $job);
References
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
23 Mar 2026
Views
30
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Perplexity 8
Amazonbot 7
Google 4
Unknown AI 2
Also referenced
How they use it
crawler 20
crawler_json 1
Related categories
⚡
DEV INTEL
Tools & Severity
🟠 High
⚙ Fix effort: Medium
⚡ Quick Fix
Set bounded queue size. Return 503 or block producer when full. Monitor queue depth. Add consumer scaling when depth exceeds threshold.
📦 Applies To
web
cli
queue-worker
🔗 Prerequisites
🔍 Detection Hints
rpush|queue.*push
Auto-detectable:
✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low
False Positives: High
✗ Manual fix
Fix: Medium
Context: File
CWE-400
CWE-770