daniel_torres

daniel_torres

Background jobs and deployment

Hi there,

I’m currently investigating Elixir and Phoenix as an alternative to Ruby/Rails for a new project I’m working on.

It’s mainly an API backend and a mobile frontend, with websocket connections between the two, but most data is going through the JSON API.

However, learning more and more Elixir and OTP, I realised we could use Tasks and GenServers for “background jobs” instead of a full fledged job queue as you’d normally do with Rails. Background jobs in our case being things like:

  • push notifications send to the mobile clients
  • emails
  • after-save calculations for our algorithms
  • image processing
  • search indexing

Now to the real question(s): say we’d use GenServers (potentially together with ETS/Mnesia) to do those things. If we deploy using erlang/elixir releases, the state in the GenServers should persists as far as I understand it, so we shouldn’t lose any unprocessed jobs. Correct?

However, if we deploy using throwaway docker containers, those unprocessed jobs would be gone after deploys.

Long story short, how would you guys handle such a thing? The aforementioned jobs are not super critical (a missed push notification is not the end of the world), but we’d certainly prefer a stable solution. Docker would also be nice from a DevOps perspective, that’s why I’m asking.

We could of course use an external queue with redis/rabbit, but that doesn’t feel like the erlang way, does it?

Hope that’s somewhat clear - thanks in advance!

Most Liked

Qqwy

Qqwy

TypeCheck Core Team

By the way, it probably is very possible to create a queue inside Elixir using the new GenStage/Flow. One possibility here would be to have a ProducerConsumer that will store its contents to the disk when its subscribers are not yet ready for the new requests.

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement