elikim

elikim

Hi!

I’m running some benchmarks and trying to see how long it takes a job to complete in chunked jobs. I’m running this query

select AVG(completed_at - attempted_at) AS average_duration, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY completed_at - attempted_at) AS median_duration
from oban_jobs 
where worker = 'MyWorker'

which I think would accurately show the execution time of a single job but it’s showing some surprising results (55s - 62s when the expectation is around a second). Do you have any suggestions on how to find the execution time of a single job in a chunk?

Thanks!
Eli

Showing Posts 1 to 5

sorenone

sorenone

Oban Core Team

Hello,

Measuring the time for a single job won’t be meaningful for a chunk. Instead, we group by chunk.

Each chunk has a leader and that’s recorded in the attempted_by column. So, here is how you could do it based on the query you sent:

with chunk_durations as (
  select max(completed_at) - min(attempted_at) as duration, attempted_by as chunk
  from oban_jobs
  where state = 'completed' and worker = 'MyWorker'
  group by attempted_by
)

select avg(duration) from chunk_durations;

The state is set to completed to prevent measuring the in-progress chunks.

Hope this helps!

elikim

elikim OP

Hi! Thank you and that definitely does help. I am seeing a bit of variance in the query and want to understand it a bit more deeply. Is attempted at set when Oban first attempts a job regardless of if the chunk is run or not?

Would the flow be something like

Oban queries for job
Oban gets job and sets attempted at
Oban checks to see if the job fits in a chunk
Chunk can be run or not

That would totally explain the variance to me as we set the chunk timeout to 10 minutes!

sorenone

sorenone

Oban Core Team

You have a great point.

That’s mostly right. The chunk will always run, even if it isn’t “full”, and the first job will always have an attempted_at.

The rest of the chunk is all fetched together when it reaches the size or timeout. You could get a more accurate value by using max(attempted_at) instead. That’s when the chunk actually starts processing.

elikim

elikim OP

Thanks @sorenone!

GishaJamesB

GishaJamesB

I noticed that first job is executed immediately, without waiting for the timeout, but rest of the jobs are fetched and executed together. Is it possible to execute first job also as part of the group?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews