Delayed Job - Quick tip against bad performance

18 February 2018 • Tags: mongodbmongoidDelayedJob

Not sure how I could have forgotten to create all the indexes that delayed job with MongoId, maybe they were added later to the gem, maybe I just forgot.

Anyways, while running a later batch of 300000 jobs to process images the performance was miserable, a job every five seconds. After a lengthy search I stumbled accross the very similar issue #650 and indeed that was my problem.

Here’s what you need to create the necessary index as found in the delayed_job_mongoid gem.

db.delayed_backend_mongoid_jobs.ensureIndex({locked_by: -1, priority: 1, run_at: 1}, {background: 1})