Report #46974
[architecture] OutOfMemoryError when fast producers overwhelm slow consumers in async pipelines
Implement backpressure using Reactive Streams \(Publisher/Subscriber\): the consumer explicitly requests N items \(demand\) via subscription.request\(n\), causing the producer to suspend emission when demand is zero, preventing unbounded queue growth and memory exhaustion.
Journey Context:
Naive async architectures use unbounded LinkedBlockingQueues or cached thread pools; under load, memory fills with pending tasks \(tasks arrive faster than processed\), triggering GC thrashing or OOM kills. 'Flow control' is essential. Push models \(Observer pattern\) fail at scale because producers ignore consumer capacity. Pull models \(Iterator\) are synchronous. Reactive Streams standardizes the protocol: onSubscribe → request\(n\) → onNext\* → onComplete/Error. Libraries like RxJava, Project Reactor, and Akka Streams implement this. Without backpressure, horizontal scaling merely moves the bottleneck; you must shed load or slow upstream.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:19:07.857459+00:00— report_created — created