Passionate Development From Journeyman to Master

Delayed Job Best Practices

Work in progress post btw..

I have been using Delayed Job quite a lot recently.

Here are few best practices that will make life easier working with it:

Run your job as delayed job locally

Our delayed job initializer looked like this: Delayed::Worker.delay_jobs = !(Rails.env.development? || Rails.env.test?)%

This means on development and test, jobs are executed immediately by the same server that schedules the job.

While it is a sensible setting for test environment, it is not for development environment. By doing this, we are not adhering to Dev/prod parity, where there is a environmental gap between environments, bad and unexpected things happen, oh yes, it has caused me hours to debug environmental specific bugs - more on this later.

Do no clear up failed jobs

Pass simple values as parameters to the job

Comments