quatermain
hello,
I have phoenix application(not important) but I have a couple of GenServers with:
use GenServer, restart: :transient, shutdown: 10_000
and I have questions:
- How can I prepare code for situation when GenServer crash down and I don’t want to lost current processing data or data waiting in queue
- How can I do queue with more same workers(GenServers) because now when one GenServer si working with some stuff another request(from phoenix or “cron”) is waiting. (some good practise?)
- Is it possible to use 3rd party queue/messages(kafka,rabbit, redis,…) without parsing params into string?
I tried using Agent with current processing state but it looks like it’s not very good idea with more “workers”
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
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
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
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
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
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
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
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
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
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 10 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Azolo
I tried this at some point, and it worked except in the cases it didn’t. Which in reality were my fault, but it would have taken some major refactoring to make it work. In other words, from my personal experience I found that this method actually caused some weird code coupling issues.
Now I would recommend a separate tracker that requires a completion acknowledgement along with a job timeout. When a job is finished then the worker acknowledges the completion and it’s removed from the tracker; when the job had a timeout, it is purged from the tracker and re-queued. This way you don’t have to keep track of the failure state or its progress through whatever job stages you may have.
If your jobs need to be ordered or aren’t idempotent then this won’t work and I wish the best of luck to you.
quatermain
I will try
idi527
Have you considered using pools of workers with something like poolboy? For saving your state I think you might trap exits in your genserver and then
terminatecallback will be called even for abnormal exits.quatermain
yes, I mean GenStage.
Yes, it solves more specific problems but technically it’s still GenServer. From their doc:
I have problems with a lot of http requests which creates even more events(jobs) and some are asynch and some synch and I can not lost anyone of course. Their solution looks like also solution for me.
idi527
Do you mean GenStage? Anyway, so far I have only found GenStage to be useful when interfacing with the outside world, when I need to put some back-pressure on the inside. It seems to be exactly what they describe in the first article that you’ve linked. They use it so as not to overload their database.
So GenStage is not an upgrade to GenServers, it solves a more specific problem, I think.
quatermain
Thanks for answers, I will look on it deeply. I found this articles and it looks very promising. What do you think?
https://blog.emerleite.com/using-elixir-genstage-to-track-video-watch-progress-9b114786c604
https://blog.emerleite.com/elixir-video-user-profile-service-for-the-olympics-application-teardown-56ac3e103d1a
GenServers looks very nice for me. They are just upgrade of GenServers.
peerreynders
Don’t Lose Your ets Tables explains the principles that
Immortal.ETSTableManageris based on.kokolegorille
The terminate function is called for clean up. Be cautious because it seems terminate is not always executed.
There is a stash example in this presentation
around 19:30…
quatermain
so do you think it’s good idea use something like this:
and
kokolegorille
You can use immortal. Or add a stash server that will store state on terminate function of dying GenServer,