Oban Pro (Extensions, Workers, and Plugins that expand Oban) — Info, News & Updates Thread

Oban.Pro is a collection of extensions, workers, and plugins that expand what Oban is capable of while making complex workflows possible.

Oban Pro v1.2 is out!

This release includes expanded priorities, defining replace in workers, notifier changes, and validation improvements which require Oban v2.17+

:card_file_box: DynamicPartitioner

The DynamicPartitioner plugin adds partitioned table support for optimized query performance, minimal database bloat, and efficiently pruned historic jobs. Partitioning can minimize database bloat for tables of any size, but it’s ideally suited for high throughput applications that run millions of jobs a week.

A synthetic benchmark of 7m jobs, (1m a day for 7 days), showed the following performance improvements:

  • 40% Smaller tables (6,281MB to 4,121MB)
  • 95% Less bloat after vacuum (4,625MB to 230MB)
  • 2.5x Faster vacuuming (28,638ms to 11,529ms)
  • 2.1x Faster reindexing (6,248ms to 2,939ms)
  • 1000x Faster job pruning (51,170ms to 49ms)

Systems with higher throughput may see more dramatic performance and bloat improvements.

See the DynamicPartitioner docs for more details and instructions on switching over.

:alarm_clock: Scheduling Guarantees

The DynamicCron plugin gained an option to improve reliability with schedule guarantees. Depending on an application’s restart timing or as the result of unexpected downtime, a job’s scheduled insert period can be missed. To compensate, you can enable guaranteed mode for the entire crontab or on an individual bases.

In guaranteed mode, jobs inserts are attempted every minute, but with uniqueness calculated to prevent any overlaps. Here’s an example of enabling guaranteed insertion for the entire crontab:

  guaranteed: true,
  crontab: [
    {"@hourly", MyApp.HourlyJob},
    {"@daily", MyApp.DailyJob},
    {"@monthly", MyApp.DailyJob, guaranteed: false},

See DynamicCron’s section on scheduling guarantees for use cases, configuration, and potential caveats.

:identification_card: UUIDv7 for Binary Ids

Now producers, batches, and workflows all use time-ordered UUIDv7 values for binary ids. UUIDv7 has natural ordering while retaining UUID compatibility, making it a direct replacement with sortability and more efficient indexing.

This change uses a pure Elixir implementation and doesn’t introduce any dependencies or new Postgres requirements.

Bug Fixes

  • [DynamicQueues] Drop unsupported :only option before calling Oban.scale_queue

Oban Pro v1.3 is out!

This release is entirely dedicated to Smart engine optimizations, from slashing queue transactions to boosting bulk insert performance.

:postbox: Async Tracking

Rather than synchronously recording updates (acks) in a separate transaction after jobs execute, the Smart engine now bundles acks together to minimize transactions and reduce load on the database.

Async tracking, combined with the other enhancements detailed below, showed the following improvements over the previous Smart engine when executing 1,000 jobs with concurrency set to 20:

  • Transactions reduced by 97% (1,501 to 51)
  • Queries reduced by 94% (3,153 to 203)

That means less Ecto pool contention, fewer transactions, fewer queries, and fewer writes to the oban_producers table! There are similar, albeit less flashy, improvements over the Basic engine as well.

Notes and Implementation Details

  • Acks are stored centrally per queue and flushed with the next transaction using a lock-free mechanism that never drops an operation.

  • Acks are grouped and executed as a single query whenever possible. This is most visible in high throughput queues.

  • Acks are preserved across transactions to guarantee nothing is lost in the event of a rollback or an exception.

  • Acks are flushed on shutdown and when the queue is paused to ensure data remains as consistent as the previous synchronous version.

  • Acking is synchronous in testing mode, when draining jobs, and when explicitly enabled by a flag provided to the queue.

See the Smart engine’s async tracking section for more details and instructions on how to selectively opt out of async mode.

v1.3.0 — 2024-01-16


  • [Smart] Skip extra query to “touch” the producer when acking without global or rate limiting enabled. This change reduces overall producer updates from 1 per job to 2 per minute for standard queues.

  • [Smart] Avoid refetching the local producer’s data when fetching new jobs.

    Async acking is centralized through the producer, which guarantees global and rate tracking data is up-to-date before fetching without an additional read.

  • [Smart] Optimize job insertion with fewer iterations.

    Iterating through job changesets as a map/reduce with fewer conversions improves inserting 1k jobs by 10% while reducing overall memory by 9%.

  • [Smart] Efficiently count changesets during insert_all.

    Prevent duplicate iterations through changesets to count unique jobs. Iterating through them once to accumulate multiple counts improved insertion by 3% and reduced overall memory by 2%.

  • [Smart] Acking cancelled jobs is done with a single operation and limited to queues with global limiting.

Bug Fixes

  • [Smart] Always merge acked meta updates dynamically.

    All meta-updating queries are dynamically merged with existing meta. This prevents recorded jobs from clobbering other meta updates made while the job executed.

  • [Smart] Safely extract producer uuid from attempted_by with more than two elements

  • [DynamicCron] Preserve stored opts such as args, priority, etc., on reboot when no new opts are set.

  • [Relay] Skip attempting relay notifications when the associated Oban pid isn’t alive.

1 Like