PLAIN/TEXT — ISSUE 285/456 COMPUTER SCIENCE · FOUNDATION / SOFTWARE SYSTEMS · ~4 MIN READING DATE: 2027-07-13 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: How a slow receiver can ask a fast sender to wait How a slow receiver can ask a fast sender to wait ================================================= / START HERE A computer can prepare images faster than a slow storage device can save them. A producer is a part of a programme that creates items for another part to handle. Backpressure is a feedback arrangement that limits sending when the receiving part cannot yet accept more work. The sender waits for permission instead of endlessly piling up unfinished items. / WHY NOW Without that feedback, a fast sender can keep filling memory with unfinished work. Temporarily slowing the sender can keep the whole pipeline useful even though it does not make the receiver any faster. / THE IDEA The receiver is called a consumer because it takes the produced items. In one demand-based design, the consumer grants permission for a limited number of items. The producer may send only up to that allowance, then waits for more permission. Finishing work makes room for the consumer to request more. This moves knowledge of limited capacity upstream. A pipeline can connect several stages, such as reading images, resizing them and writing them. A slow writer should eventually slow image reading, rather than letting each earlier stage independently pile up an unlimited collection. / THE FORMAL IDEA remaining allowance = requested items − items delivered - All quantities are item counts, not processing speeds. A request for three items means permission to deliver three, not a promise to finish them within three seconds. - Allowance must never become negative in this simplified protocol. Further requests add permission; delivery uses it up. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. The consumer requests 3 images. Allowance becomes 3. The producer delivers A, B and C. Allowance becomes 0 and sending pauses. After finishing A and B, the consumer requests 2 more. D and E may now arrive. Change the first request to 1: only A may arrive before the next request. The smaller request reduces how far ahead the producer can run. It can also reduce overlap between stages, so choosing an allowance trades spare capacity and smoothness against stored unfinished work. Neither request size changes the time needed to resize a particular image. / SO WHAT? Feedback must reach the source that can actually slow down. An unpausable sensor or outside event stream cannot be made slower by wishful thinking. The system then needs an explicit policy: save elsewhere, reject work, sample it, or discard selected items according to its purpose. Moving an unlimited queue to another stage is not backpressure. / ONE CAVEAT This describes demand-based flow control, not every possible protocol. Cancellation, failures, item sizes and concurrent requests need precise rules; counting items alone may not bound memory when item sizes vary greatly. / KEEP THIS When a receiver controls how much unfinished work may arrive, overload becomes a sending decision instead of unlimited hidden accumulation. / SOURCE TRAIL [1] Reactive Streams — Backpressure goals and scope https://www.reactive-streams.org/ [2] Reactive Streams — Request and delivery rules https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.4/README.md NEXT: Why a thinner tube can draw water higher --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/07/2027-07-13-producer-consumer-backpressure.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click