talira

GenStage

Producer and consumer stages with back-pressure for Elixir

commercial softwarefree

GenStage is the Elixir team's library for exchanging events between producer and consumer processes with back-pressure: consumers send demand upstream, and producers emit events only as that demand arrives, so a slow stage never floods a fast one. It provides the GenStage behaviour for producer, producer-consumer and consumer stages, dispatchers that decide how events reach several consumers, and ConsumerSupervisor, which starts a child process per event. Flow and Broadway are built on it. It runs on Elixir.

Problems it solves

  • stop a fast Elixir producer from overwhelming slow consumer processes
  • build a multi-step processing pipeline of Elixir processes with back-pressure
  • start one supervised process per job pulled from a queue in Elixir

Features

  • GenStage behaviour for producer, producer-consumer and consumer stages
  • Demand-driven back-pressure between stages
  • DemandDispatcher and BroadcastDispatcher for sending events to several consumers
  • ConsumerSupervisor, which starts a child process per event
  • Examples for pipelines, rate limiting and a GenEvent replacement

Limitations

  • Its repository has no LICENSE file and its source files carry no licence notice; only mix.exs and the README name Apache-2.0 ("Same as Elixir")12

Alternatives

The same job

These do what GenStage does.

  1. Broadway Concurrent, multi-stage data ingestion and processing pipelines in Elixir

Compare GenStage with the top 3