How to Isolate Job Processing Performance Between Tenants with Ash Multitenancy and Oban?

I’m currently using Ash framework’s multitenancy in our application, and it has been working great for managing tenant-specific data. We’re also using Oban to handle background jobs, and I have a specific use case where I’m not sure how to best handle job processing across different tenants.

The current setup ensures that jobs within a single tenant are processed in sequence, which is working as intended (similar to having a queue size of 1 per tenant). However, I would like to achieve parallel job processing between different tenants, ensuring that one tenant’s jobs do not affect the performance of jobs from another tenant. The tenant is currently stored as an argument in the Oban job.

Is there a way to configure Oban to process jobs concurrently between different tenants, while still maintaining the sequential order within each tenant?

Any guidance or best practices on how to achieve this would be much appreciated!

Thanks in advance!

There’s nothing in OSS Oban that will facilitate sequential processing between tenants like that. However, Oban Pro offers two mechanisms that could achieve what you’re looking for:

  • Chaining — chains ensure that jobs will run in a strict sequential order, and you can partition them by a tenant id so the tenants run in parallel.
  • Queue Partitioning — splits the queue on the tenant id globally to allow those jobs to run in parallel without effecting the others. This would prevent the tenants from impacting each other, but it won’t ensure they run in sequence like chains do.

Hope that helps!

1 Like

Thank you! I love Oban :slight_smile:

1 Like