dch

dch

Separating Consumers from Producers in different BEAM instances

Overview

For security compliance reasons, I need to ensure a complete separation between some of the consumers, and the producers that submit jobs to the queue. It’s sufficient to have the jobs go to a common PostgreSQL instance, but the Erlang VMs must be separate, to provide a strong security boundary.

In the past I’ve used RabbitMQ very successfully, but we don’t have a message broker yet in this project, and Oban’s workflows will be very useful for other aspects of the project.

Limitations

This rules out Erlang distributions obviously, and also PG Bouncer, but this is still enough to run Oban successfully using PostgreSQL LISTEN/NOTIFY. I asked this question on Slack, and got enough of a feel to implement this, so far it seems to work well enough.

Questions

  • have I missed anything obvious from the proposed solution?
  • has anybody been down this path, and has some war stories to share?
  • are there any other patterns to deal with this situation?
  • what’s the best way to notify the Producer that the work has completed? Note there’s no PubSub available between nodes. I found PostGrex.Notifications & Postgrex PubSub as well as Oban.Notifier

Current Solution

  • a front end Phoenix app, with migrations, and Oban job submission

  • a backend Elixir app, without migrations, but sharing Repo & Oban config

  • a common Oban.Worker library module, used in both apps

  • the primary has no queues defined via queues: []

  • the secondary has the necessary queues defined queues: [default: 10]

  • for notification the built-in Oban.Notifier is a better choice and works with the same underlying mechanisms.

Marked As Solved

sorentwo

sorentwo

Oban Core Team

Nothing obvious to me. It’s fairly common to split up Oban between worker and non-worker (i.e. web) instances. In that case the worker code is usually shared between the applications, but that’s not a requirement.

Queue producers don’t need to know when work is completed, just that jobs are available. That’s one of the many places where PubSub notifications are used for coordination between nodes. The others would be for starting, stopping, pausing, resuming, and scaling queues; not to mention sharing metrics for Web.

The default notifier is Postgres based and there’s no need to bring in a separate Postgres notifier. That will work perfectly fine as long as the nodes running jobs share a database, and there isn’t a connection pooler.

Your current solution is spot on. This is something people ask about frequently and should probably be in an offiical guide.

Also Liked

sorentwo

sorentwo

Oban Core Team

For splitting the application, there’s no difference at all. Performance is mostly limited by the power of the database and your usage patterns.

The Postgres notifier is similarly limited. It requires additional transactions to emit events, and it can’t handle large payloads for metrics. Disabling insert triggers cuts down on the number of notifications drastically though.

Where Next?

Popular in Questions Top

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
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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...
274 41539 114
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
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
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

We're in Beta

About us Mission Statement