swelham

swelham

I’m trying to put together a plan for a library that I am working on whereby I need to provide an interface that allows the client to asynchronously call out to external APIs (HTTP endpoints in this case). I also need to make sure that this is rate limited to adhere to the rate limiting on the externals APIs.

From what I have read GenStage sounds perfect for this and using a ConsumerSupervisor I would be able to dynamically start workers for each request as they come in and let GenStage limit the number of workers it will start concurrently.

Does anyone know of any good examples of this type of setup in practice?

I am trying to get my head around how this all fits together and feel a real world example would help me out here.

Showing Posts 1 to 10

mechabyte

mechabyte

Discord published a blog post covering how they use genstage to buffer calls to Firebase APIs. It has some code examples as well as performance statistics.

swelham

swelham OP

That looks awesome thanks @mechabyte. I will have a proper read through when I get home from work.

swelham

swelham OP

In addition to the discord article linked above, I came across this talk which is probably the best explanation and demo of an end to end genstage setup I have come across.

Well worth a watch (especially if you’re new to genstage)

krapans

krapans

Nice. haven’t seen this talk yet. :slight_smile:

Q: Is there use case for GenStage for example for simple CRUD API calls for users, projects, etc. Just for simple data requests?

swelham

swelham OP

From my basic understanding so far I would say yes there is. Genstage looks to be a great fit for when you’re having to deal with external forces such as networking for example (rest apis, databases, etc…).

It allows the workers to dictate how much work they are given which prevents the likely important part of the system being overloaded and to remain free to do its thing and cause the backup of events further up the stack.

Someone please correct me if I have got that wrong.

krapans

krapans

Ok, this sounds cool. Is there any example of how you write GenStage server for example for User CRUD module? I don’t have an idea how you manage those actions in GenStage server.

swelham

swelham OP

I would suggest definitely take the 40 minutes to watch that talk as that will probably answer your question better than I could.

The demo is a restruant simulation which demonstrates the full cycle of tables placing an order (that’s processed through genstage) and then receiving thier food all within strict timeouts. Akin to sending CRUD data into genstage and receiving some data when it’s finished.

krapans

krapans

Ok, super. Added to my tomorrows to do list. Thank you! :thumbsup:

wfgilman

wfgilman

Here’s a simple example of a multi-stage pipeline. I found Jose’s talk really helpful (linked in example).

swelham

swelham OP

Thanks @wfgilman, that’s a very interesting example. I haven’t seen any others that are dynamically starting and linking multiple stages like that.

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews