Could you explain min_demand and max_demand in GenStage?

  • The initial demand is 1000 (max_demand).
  • The producer releases 850. The producer owes 150 events.
  • GenStage releases 500 (min_demand) of the 850 events to the consumer.
  • Genstage releases the remaining 350 events to the consumer
  • As min_demand of the max_demand has already been consumed by the consumer 500 events (min_demand) are demanded by GenState to be buffered
  • The producer receives 500 demand while still owing 150. So demand is actually 650. Producer erroneously releases 850 events, exceeding demand by 200. Total demand is 1500 but producer released 1700.
  • Genstage releases 500 (min_demand) to consumer (1350 running total)
  • Genstage releases 150 events to consumer to total demand level of 1500.

I suspect that at this point things start to go off the rails because the producer is not adhering to the protocol (it’s releasing more events than are demanded).


4 Likes