sezaru

sezaru

Is there any limitations in Oban queue size with the DB?

I have a requirement for my system where I expect to run jobs that will just call external APIs and then store the data.

I don’t have control on how much time these APIs calls can take, so technically, I can have an API call that will just wait for, I don’t know, 30 minutes before it returns something back.

This means that, if I use Oban to run these as oban jobs, I can have multiple jobs basically “doing nothing” just waiting for a reply from the api server.

The issue I’m having is deciding on a queue size for this.

If I have a small number of concurrent jobs in my queue, then I risk filling up all the available slots with “slow jobs” that take a log time to finish and blocking other jobs from starting.

At the same time, if I make the queue size very large, I think I will have issues with DB connection since, AFAIK, Oban requires a connection for queue slot, at least that’s what I got from this:

Consider the total concurrency across all queues. For example, if you have 4 queues with limits of 10, 20, 30, and 40, your system needs to handle up to 100 concurrent jobs, each potentially requiring database connections and other resources.

It’s not clear to me if the “requiring database connections” here just means that, the code that runs inside the job can require a DB connection, or if it actually means that Oban itself creates that connection when the job is running.

So, can you give me some suggestions on a good strategy for this?

Marked As Solved

sorentwo

sorentwo

Oban Core Team

If you don’t want those slow or hanging API calls to block the queue, you can use a timeout to ensure the job doesn’t block the queue and retry it later.

The concurrency limit on your queue has little bearing on the total number of DB connections. A connection is only needed for fetching and acking jobs (and Pro does that with a single transaction).

You nailed it—it means that the code running inside the job may require DB connections. Oban does not hold a connection or transaction while the job is running. Doing so would be horrible for concurrency.

Feel free to set a higher concurrency limit (50, 100, whatever suits you). You should also consider a timeout to prevent the queue from clogging after a batch of slower API calls though.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
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
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
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
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
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
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement