fchabouis

fchabouis

Hello,
This is my first question here, please let me know if it can be improved.

Every night, I would like my server to run a validation process on a number of urls. It computes some hash, download some data, validate it, etc.

It looks like tasks are best suited for this. I’ve also read that supervised tasks are better than just creating unsupervised tasks, for the clean-up, in case the main process is terminated. Can you confirm that I’m taking a good direction so far ?

Also, my server is running on a small instance, I’m worried that if I give it a big list of tasks, it will just crash because of the small resources I have available. I was hoping that the Task.Supervisor would have an option about the maximum number of concurrent tasks running, but I didn’t see any. Any information about this ?

I saw async_stream had a concurrency limit option, but didn’t understand if it could be helpful for my situation. Is it ? And is it compatible with a Task.Supervisor ?

Probably many newbie questions here, thanks for your time !

Showing Posts 1 to 2

hauleth

hauleth

Do not worry. BEAM uses preemptive scheduler (at least from the viewpoint of the user) so it should be ok to spawn new process per each URL (depending on the scale) and just let VM do its magic. Erlang processes are quite cheap, so this should not be a problem if there is list of 100s of URLs, I would start thinking about any throttling only if there would be over 1k of such. In that case you can use GenStage which allows for rate limiting.

gregvaughn

gregvaughn

I use Task.Supervisor.async_stream_nolink/6 in several places for this sort of thing. The tasks are supervised by the supervisor in the first param, but they are not linked to the caller. In the caller, I then Enum.reduce over the resulting stream and collect a little “report” of number of successes/errors/etc and log the result.

I typically specify the concurrency and unordered settings in the options. This concurrency throttling mostly helps me to not overwhelm some external API that the tasks call. It’s not because I’m worried about the BEAM handling a large number of tasks.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
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
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
Stef-Verniers
Hello I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New

Other Trending Topics Top

dominicletz
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
mudasobwa
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
KristerV
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews