tellemiller

tellemiller

Cache hit ratio on oban_jobs at 65% - large completed backlog, is this expected?

We recently started running Oban with Oban Web on PostgreSQL (AWS RDS gp3) and noticed our oban_jobs buffer cache hit ratio sitting at 65%, with ~600 block reads per second. We investigated and wanted to share findings and ask a few questions.

What we found

Our table has ~434k rows, of which 433,371 (99.97%) are in the completed state. We have max_age: 7 days configured on the Pruner. Table size is 301 MB, index size 229 MB (560 MB total). Autovacuum is healthy, dead tuples at 8.1%.

The main query we traced the block reads to was Oban Web’s queue typeahead suggestion:

SELECT DISTINCT o0."queue" FROM "public"."oban_jobs" AS o0

The composite index from v08, (state, queue, priority, scheduled_at, id), has state leading, so this query can’t use it efficiently and falls back to a large sequential scan. It’s worth noting, we also suspect some of our sequential scan count was inflated by developers running diagnostic queries during the investigation itself.

Actual performance metrics are all fine: avg read latency 0.6ms (peak 0.8ms), ReadIOPS at 650 of 3,000 available, 1.2GB freeable memory. So this isn’t causing a real problem today.

Questions

  1. Is a 65% cache hit ratio on oban_jobs expected at this scale with a large completed backlog? Given our real metrics are healthy, is this simply a normal consequence of the table size relative to shared_buffers?

  2. We’re reconsidering our 7-day retention, but job retrospection is genuinely useful to us. What does effective pruning look like in production for teams that want to retain some history without the table growing unbounded?

  3. For the Web typeahead query: queue names are statically defined in our config, so a full table scan to populate suggestions feels unnecessary. The hint_query_limit(:queues) resolver callback seems like the right lever to limit the scan, but has a resolve_queues style callback been considered, to allow serving suggestions directly from known config rather than the DB?

First Post!

sorentwo

sorentwo

Oban Core Team

That query would only run once every 5 minutes because it is cached locally. A sequential scan is expected in this case. Most of the typeahead queries, and the composite filters they help compse, aren’t index backed because they’re infrequent.

That’s entirely possible. Most of that data wouldn’t be accessed frequently under normal circumstances, and Oban will hit indexes for frequent queries.

The fewer jobs you retain, and the leaner you keep the table, the better performance you’ll have in general. One solution for keeping older jobs is DynamicPruner’s before_delete callback.

Active queues are vailable via Oban.Met.labels/1, or Oban.Met.checks/1, but queues you want to filter by aren’t always actively running. Or, you’re running multiple Oban instances that share a single database, or using Web to inspect Python jobs. In all of those cases, the database is the only real source of truth.

Where Next?

Popular in Troubleshooting Top

bugnano
Hello everyone. I’m the author of GitHub - bugnano/wtransport-elixir: Elixir bindings for the WTransport WebTransport library · GitHub ,...
New
anotherpit
Summary A downstream job that deps on a graft correctly waits for the grafted jobs at one graft level, but stops waiting when the workflo...
New
hyperoceanic
Having read the book, I’m keen to explore Ash a bit more, but I’m falling at the first hurdle - the creation of a new project. Here’s my...
New
ktayah
Environment Oban Pro: 1.7.6 Oban: 2.22.1 Issue When a sub-workflow built with Workflow.put_context/2 is attached to a parent via ...
New
Lotoen
Hello, I am currently using Elixir 1.18.4 and OTP 27 with Linux Mint 22.3 - Cinnamon 64-bit as my operating system. I came across this er...
New
tellemiller
We recently started running Oban with Oban Web on PostgreSQL (AWS RDS gp3) and noticed our oban_jobs buffer cache hit ratio sitting at 65...
New
rayex
For hex package islands_score the source @spec for function format/2 is as such: @spec format(t, keyword) :: :ok Why does it show on 4 ...
New
anotherpit
A graft inside another graft causes Oban.Pro.Workflow.status to recurse forever. oban_pro 1.7.5 defmodule App.NestedGraftRepro.Test do ...
New
Lotoen
Hi, I’m on Linux Mint 22.3 - Cinnamon 64-bit, and I encountered an error when trying to build an elixir phoenix container 577.1 Reading...
New
ndan
Oban.Pro.Migration.up(version: "1.7.0", only: :indexes) fails on partitioned oban_jobs table when upgrading Oban Pro from 1.6 to 1.7 def...
New

Other popular topics 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
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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
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
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
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
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
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement