Iex.new
Hi,
in our Team at work we have Hackathons and for next year I am thinking about to introduce Elixir. As we have todo with data processing in our daily work I planning to propose a small app that should import data in parallel from a huge csv file (let say for example a list of persons) into a database. And maybe to transform the data in between.
I think I would also like to show the results in the front end using Pheonix.
During my research I came across Flow and Broadway.
As I have not so much experience with Elixir and never used Flow/Broadway, what could be a good fit for my experimentation ?
I find this article on dev.to which seems to close to what I want to do :
Thank you!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Hello all. I have a question as to best practices for code organization when implementing a liveview with a lot of responsibilities.
Sup...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #processes
- #security
- #api
- #forms
- #performance










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
D4no0
How big the CSV is? What is the policy on failure and restarts of the server, meaning do you need persistence in processing?
If you don’t have any special requirements, I would just recommend to use Oban. You can just simply stream the file contents into small to medium jobs, then process them concurrently with Oban without having to care about anything else, you will have features like rate-limiting and persistence out of the box.
Iex.new
I think something like 2GB.
I do not have any policies at the moment as I am just starting to think about the “workshop” and things that could be nice to show. As we do not have so much tome (2 days) I would like something small but that also give a good overview of what is possible to do.
joey_the_snake
Flow would be a good fit for this
dimitarvp
If you don’t want to store future and current tasks state you can just get away with
NimbleCSVandTask.async_stream/3, very easily:Flow and Broadway are awesome but for a 2GB file the above will serve you just fine. I’ve processed files up until 17GB or so, if memory serves.
Again though, if each record – or a batch of records – takes more time to process then you’ll need to have more persistent workers where
Obanwill be much more suited.Iex.new
@dimitarvp, thank you!
Yesterday I was able to implement what I wanted to do with the solution you proposed
In my process I check with the lib
file_systemif a new file was detected in a specific directory and if yes then it will proceed. Each line of the CSV file is correctly imported into a MySQL database. For that, I have used Ecto.When trying to set up Ecto, it was proposed to set up my Repo in the application.ex file like :
config/config.exs:
In the Ecto documentation, the namespace is not the same:
In my case, I have tried to define MyApp.Store but this did not work for me.
So I have some questions …
:
MyApp.Storeinstead of onlyStore?If I understand correctly the first one is to set
Storeas available Ecto Repo and the second one is for the database configuration. Correct?This is the code I ended with based on what you wrote:
dimitarvp
Glad you made it work!
I can offer you something that can accelerate the code further: you can put
Stream.chunk_every(500)afterYourCSV.parse_stream()and then theTask.async_streamwill accept a batch of 500 records (not a single record).And then you can do batch inserts – provided you don’t do Ecto validation that is. If you need validation then inserting one by one is still better.
Also
Task.async_stream’s optionmax_concurrencywill depend on your repo pool size in this case. F.ex. if your repo has a pool of only 20 connections then you should change themax_concurrencyto 20 (or even 18-19). So have that in mind as well, it’s important and you might see a lot of timeout failures ifmax_concurrencyis too high.Iex.new
thanks for the hint !
I have tried with 100 000 000 rows but only 62 733 738 have been imported.
I got some errors like:
I think I will have to tune better the pool (100) and the number of max_concurrency (100).
I will play a bit with it.
What do you think about the questions I asked in my previous answer regarding the namespace and configuration?
dimitarvp
If the MySQL instance itself is telling you “too many connections” maybe you should look into its own config – maybe it is not configured to accept that many? I mean you can allow Elixir to connect to 100 separate MySQL connections (on the same server) but if MySQL is configured to e.g. allow maximum 80 (just an example) then you’d get an error like that.
So it’s time to check MySQL’s config itself.
Yes, always scope your app’s modules. Never leave top-level modules unless you’re 100% convinced you’ll never get a collision. Which if you say “I am sure” would be famous last words because who knows who will try to integrate with your app / library in the future…
Yes, correct, hence it’s not possible to remove one or the other. The first setting comes in handy if you have several repositories.
Iex.new
Thank you @dimitarvp !
dimitarvp
I’m curious if you fix the connection errors. Please let us know.