If you've ever configured a GenStage or Broadway pipeline by copying max_demand
and min_demand numbers from a blog post and hoping for the best, Elixir core
team member Andrea Leopardi has written the piece for you:
Elixir's GenStage Demand (a Visual Explainer).
The framing that makes it click: concurrency gives us more workers; demand tells
us when to stop sending them work. Back-pressure is the whole point of GenStage,
and the post walks through it visually. max_demand caps how many events can be
in flight for a subscription at once, while min_demand is the threshold that
triggers the consumer to ask the producer for more. Seeing the numbers flow
between stages makes it obvious why the defaults behave the way they do, and
what actually changes when you tune them.
Andrea co-wrote Testing Elixir
and his posts are reliably worth your time. This one deserves a bookmark for the
next time someone on your team asks why their pipeline sits idle in batches, a
question min_demand usually answers.