beto
How to handle background jobs with elixir/phoenix
Hello, I am working on an task, that requires to parse a csv sent from a react frontend. When the backend receives it, it should make an API call to a webservice. But now the csv is large and it’s not functional. My idea is to get the csv, answer the frontend and process the csv and API calls in the background, but I have no idea where to start. Can someone point on a tutorial or something on how to start? If there a way to avoid rabbitMQ redid would be better, if possible
Thank you very much
Most Liked
cnck1387
When I first came to Elixir, this was one of the biggest questions I had.
I think it would be really beneficial if there were a few blog posts and open source projects that went over a few production-ready solutions to handle cases like this. I think it would really help people using Elixir who are coming over from Rails or other stacks with the “web app + worker + redis” mentality.
Some of the use cases could be:
- You don’t care about the response
- You do care about the response
- You need it to persist across beam reloads
- Handle rate limiting (X per minute style)
- Handle retries (constant or exponential back-offs) and hooks for custom things to happen on error
rjk
If you do it like this (without a job processing library, which is fine) keep the things in mind that are described in this article from Chris McCord Phoenix Tips and Tricks - DockYard under the title “Avoid Task.async if you don’t plan to task.await”. The summary is that if you want to use Task.async to process your CSV file, hook it into it’s own Task.Supervisor so that it is isolated from the controller.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









