rm-rf-etc

rm-rf-etc

First of all, I realize that both flow and broadway are built on top of genstage.

I find flow a bit confusing, compared to how broadway is presented. Probably because flow is trying to be applicable to many more uses than just data pipelines.

My Use Case:
I’m fetching from an API and need to run many requests as fast as possible, in parallel. And it’s time-series data with associated sensors. First I fetch a list of sensors (~1,000 of these), then, for each sensor, I will fetch the time series data in 1 day chunks, between now and some selected date in the past. Then I will pipe all chunks to my postgres+timescaledb database (calling Repo.insert_all/3 per batch).

Based on my what I’ve read and watched, it sounds like broadway would be really ideal, but it seems as if writing my own producer/producer-consumer/consumer is or was not the original intent of the authors. And I’m saying this just based on how the readme comes across to me. Please correct me if I’m wrong.

Flow doesn’t seem as nicely tailored to processing data like I’m doing, and also doesn’t seem as approachable.

Could somebody please advise me as to which of these I should make my focus?

Also, does it make sense to do postgres bulk inserts from parallel consumers? My guess is that it does not. The folks at TimescaleDB recommend a raid 0 array of a small number of drives, and to put the WAL on a separate disk from the data to get better bulk insert performance, but I assume parallel writes are still not supported. Could somebody tell me how this works with elixir? Does elixir run a single process for all DB queries, regardless of how many processes I have sending DB write requests?

Showing Posts 1 to 10

stefanchrobot

stefanchrobot

My take is that there are some common producers provided, but the rest is up to us. Nothing wrong with building your own producers/consumers. Last time I read the docs, the takeway was to limit the number of producer-consumers like in GenStage.

(I’m assuming that you’re using Ecto). No, it has a pool of connections so you can query the DB in parallel. But then you need to check how much the DB is able to sustain.

dimitarvp

dimitarvp

This is definitely not true. The Elixir community in general strives to include only the minimal batteries and is more about giving you high-quality LEGO blocks with which you build your own thing. As @stefanchrobot said, don’t be shy about building your own custom parts when the need calls for it. :slight_smile:

If you would like to get good advice you’ll need to share some more details, f.ex.:

How often does this happen? Say, once an hour? Once every minute? Also, it’s not clear if you need to call the external API on as many requests as possible VS. you first calling that API and then doing many parallel requests to… where? Another API?

We lack enough details to give you a recommendation.

We don’t know anything about in which business you operate, how loaded your system is, and do you actually need those scaling advises that the folks gave you. From what I’ve seen from my freelancing career, most people tend to overestimate their hosting needs.

Truth is, my i3 CPU Linux laptop can easily handle dozens of thousands of writes per second when connected via an Ethernet cable on the same local network as my much beefier workstation.

So don’t rush introducing huge complexity to your setup – unless you haven’t shared with us that you already need to scale your DB servers.


All in all, we need more details. I personally never used Flow once. Every time I felt I could, I just got away with a few supervised processes that periodically do Task.async_stream-based algorithms, and never had a problem.

rm-rf-etc

rm-rf-etc OP

I’m not building a web server, it’s a tool for personal use. What I’m trying to accomplish is to seed my database from an external API so that I can do statistics on the data, and I want the seeding process to complete in a reasonable amount of time.

dimitarvp

dimitarvp

You still need to tell us if that external API won’t ban you if you do 50+ requests at the same time, being one example.

rm-rf-etc

rm-rf-etc OP

No, it has not banned me. I’ve had many successful tests so far, even though my pipeline is not fully working at this point.

How do I figure out how many concurrent writes my postgres can handle? Yes, I’m using Ecto.

dimitarvp

dimitarvp

This StackOverflow thread could help.

This article is not bad as well.

kokolegorille

kokolegorille

You have two distinct actions, one is to schedule, the other is to fetch…

Schedule is something different, but You could have GenServer (maybe one per sensor), triggering event periodically, that will put job in a GenStage pipeline.

Then, the pipeline will achieve its work, even under load pressure. You will achieve concurrency by specifying the number of producer/consumer.

Beware of not going too fast, and not flooding your database.It happened to me when trying to crawl a website and saving to db. I was doing insert_all with potentially too much data, and postgrex did not like it that much.

GenStage helped me to have a better control of concurrency.

Flow would be nice if You have aggregation per sensor, but it seems not, as You just insert this into db.

chasers

chasers

Create a buffer process. Generate a job for each sensor day combo you need. Queue up those jobs in your buffer. Create a Broadway producer for your buffer and in the Broadway pipeline pull the data, batch it and insert. Scale up producer consumers as needed.

kokolegorille

kokolegorille

Yes, that is the path to follow…

josevalim

josevalim

Creator of Elixir

It is expected for you to write your own GenStage producers and plug them into Broadway. There is even a guide that covers this: Custom Producers — Broadway v1.3.0

However, the producers_consumers and consumers are Broadway responsibility, you can’t plug them in.

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