amacgregor

amacgregor

GenStage usecases and best practices

Elixir Noob here, I’m looking for advice about GenStage and some general guidelines when designing systems with Elixir.

At a high level, I’m looking to build a system where the end-user can modify/select each stage of a data pipeline, the start and end of said pipeline will always be the same, but the end user can add/activate a new stage that will do the additional computation.

Will using GenStage and the Flow module be a good fit for the usage I described? if so any examples or advice anyone can offer in regards to the implementation?

Cheers!

Most Liked

josevalim

josevalim

Creator of Elixir

Your description of the problem is very vague to say if GenStage or Flow is a good fit. I would first worry about writing the application and business domain. As an Elixir beginner, there are a couple things you would need to learn before dynamically managing GenStage pipelines, such as managing simple processes, and you can reevaluate later if you need the performance characteristics or the backpressure provided by GenStage.

To put it shortly, start with the simplest abstraction until you are familiar and you are sure you need more complex ones.

LostKobrakai

LostKobrakai

Not really. GenStage servers are just GenServers as well, but they have some extra functionality build on top for handling events in a chain of producers and consumers (or producer/consumers which do both things), reducing the boilerplate needed to set those up. Flow is another layer of abstraction on top of that which handles common cases like faning out to multiple processes and reducing those back at a later stage.

All this could be done using plain GenServers as well, but you’d need to write a ton more code to wire things up. Also each of those servers, be it a genserver or genstage instance still works syncronously on it’s own events. It’s multiple of those servers, which makes things async.

amacgregor

amacgregor

Thank you Jose, then I’ll do as you advice and go work on my basics before jumping into GenStage

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement