---
title: "Elixir's GenStage Demand (a Visual Explainer)"
url: https://daily.dev/posts/elixir-s-genstage-demand-a-visual-explainer--si6zgwh3q
source_url: https://andrealeopardi.com/posts/genstage-demand-visualized
type: article
source: "Awesome Elixir"
published: 2026-08-13T20:23:29.115Z
updated: 2026-08-13T20:32:42.089Z
tags: ["elixir"]
reading_time: 11
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Elixir's GenStage Demand (a Visual Explainer)

**[Awesome Elixir](https://daily.dev/sources/awelix)** · 11 min read · 0 upvotes · 0 comments

## Summary

A visual, interactive explainer of how Elixir's GenStage library implements demand-driven backpressure between producers and consumers. It walks through the core problem of unbounded queues, introduces the concept of demand as a bounded counter, and explains max_demand and min_demand settings with animated playgrounds. It also covers how multiple consumers subscribe independently to a producer, how the DemandDispatcher routes events based on demand, and mentions Broadway as a higher-level abstraction built on GenStage.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://andrealeopardi.com/posts/genstage-demand-visualized>

## Questions this post answers

### What do max_demand and min_demand mean in Elixir GenStage?

Max_demand sets the maximum number of events allowed in flow for a subscription and also the size of the first request a consumer sends. Min_demand is the remaining-demand threshold that triggers another request; for example, with max_demand 6 and min_demand 2, once only 2 units of demand remain, the consumer asks for 4 more events, letting the producer fetch while the consumer keeps working.

_daily.dev surfaces deep dives like this for developers tuning concurrent pipeline throughput._

### How does GenStage prevent a fast producer from overwhelming a slow consumer in Elixir?

GenStage requires the producer to send only as many events as the consumer has explicitly requested through a numeric demand count, rather than pushing events at its own pace. The consumer says 'you may send n more events,' not 'send n events per second,' so an idle or slow consumer simply stops receiving new events until it asks again, keeping the in-flight queue bounded.

_developers designing bounded queues can track this kind of backpressure pattern on daily.dev._

### How does GenStage route events when multiple consumers subscribe to one producer with different processing speeds?

The default DemandDispatcher sends events to the subscription with the most outstanding demand, so faster consumers that finish work sooner and hit their min_demand threshold ask again more often and receive proportionally more events. Slower consumers naturally receive less work because they request less frequently, without the producer ever measuring their actual speed.

_engineers comparing dispatcher and load-distribution strategies can follow this topic on daily.dev._

## Similar posts on daily.dev

- [Building Custom Producers with Elixir's Broadway](https://daily.dev/posts/building-custom-producers-with-elixir-s-broadway-filigzycw) · ElixirStatus · 1 upvotes · 0 comments
- [Designing Data Flow in an Elixir Trading System](https://daily.dev/posts/designing-data-flow-in-an-elixir-trading-system-osvsj2vrv) · ElixirStatus · 0 upvotes · 0 comments

---

Tags: [#elixir](https://daily.dev/tags/elixir)

[View this post on daily.dev](https://daily.dev/posts/elixir-s-genstage-demand-a-visual-explainer--si6zgwh3q)
