Understand Consumer Demand

Learn how the producer and consumer interact when they supply and process processes.

Consumer demand

We previously saw that PageProducer was asked for 1,000 events. We may wonder where the number comes from. By default, stages of the :consumer and :producer_consumer type ensure that the demand for new events is between 500 and 1,000. We can configure this through the min_demand and max_demand settings. When a consumer subscribes to a producer in the init/1 function, we pass a tuple with some configuration options:

#`subscribe_to` options can be a list of tuples.
sub_opts = [{PageProducer, min_demand: 500, max_demand: 1000}]
{:consumer, initial_state, subscribe_to: sub_opts}

Get hands-on with 1200+ tech skills courses.