talira

Flow (Elixir)

Parallel computations on collections for Elixir, on top of GenStage

open sourceApache-2.0free

Flow lets Elixir developers express computations on collections much like the Enum and Stream modules, but runs them in parallel across several GenStage stages. A pipeline such as counting the words in a file can read with from_enumerable, transform with flat_map and map, partition the data and reduce each partition in parallel, then hand the result back as a list. Flow.stream with link: false turns a flow into a stream that isn't linked to the calling process. Not the Flow command-line tool (ss3d2chg).

Problems it solves

  • process a large collection in parallel in Elixir
  • count words in a big file using all CPU cores in Elixir
  • run Enum-style pipelines across multiple processes

Features

  • Enum- and Stream-like operations that run in parallel
  • partitioning and per-partition reduction
  • built on GenStage stages
  • convert a flow to an unlinked stream

Limitations

  • Flow pipelines start processes linked to the current process, so an error shuts down a Livebook runtime unless you use Flow.stream(flow, link: false) or trap exits first.1

Alternatives

The same job

These do what Flow (Elixir) does.

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

Compare Flow (Elixir) with the top 3