Choose the Right Dispatcher
Learn how GenStage uses different dispatchers to send events to consumers.
Introduction to dispatchers
There is one important component of GenStage
we haven’t talked about yet—the dispatcher. When :producer
and :producer_consumer
stages send events to consumers, it is the dispatcher that sends the events. So far, we’ve used the default DemandDispatcher
, but GenStage
comes with two more. Let’s see what they do and how we can use them.
DemandDispatcher
We can specify the kind of dispatcher to use when we initialize the process using the :dispatcher
key. The default is DemandDispatcher
, which is equivalent to this configuration:
Get hands-on with 1300+ tech skills courses.