I wanted to know RI Rails Community's opinion on A...
# our-work
c
I wanted to know RI Rails Community's opinion on ActiveJob. I have to write a scheduled set of queries at midnight. Would you recommend ActiveJob or a rake task run via CRON? In case I go with ActiveJob, what is your current opinion on the set of job runners? Is default Rails Job implementation okay or Sidekiq or Resque or something else?
@rich-notebook-79324 @victorious-energy-56764
b
It depends on what you have in place for scheduling and how well that works for you. We use both resque-scheduler and sidekiq-cron in production and there are no problems. I have heard good things about https://github.com/javan/whenever too. Or you could go the plain cron route and invoke whatever code you want with crontab entries. You should see what fits best in your project, deployment strategy, etc.
👍 1
v
Clockwork is a slightly better option for scheduled jobs.
👍 1
The best option is Sidekiq Ent
👍 1
r
Have used whenever in the past. it is good to schedule one off rake tasks that run at specific time
advantage is that you are not tied to any of the active job backend, the rake task just runs as a process
if the rake task needs to do too many things I invoke background jobs from the rake task
one more advantages of whenever is Ruby DSL over cron
👍 1
c
Thanks for all the pointers, experiences and opinions. Going with rake tasks with background jobs for now. Will try to experiment with Whenever/Clockwork. In the future if scale becomes a bottleneck, will check other solutions.
v
I might be repeating something you already know -- but a word of caution for others who read the thread: Make sure your jobs are idempotent. This is the single most important factor for background jobs. Any other design will get brittle fast.
c
Thanks a lot, @victorious-energy-56764, pertinent reminder.
r
Make sure your jobs are idempotent.
Yes this is very important
a
On contrast to above suggestions, rake task via cron gives me more peace of mind because the execution of cron is now system/OS headache instead of application layer, hence more reliable.