Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 30, 2019 08:00 pm GMT

Call for Contributions: Move All DelayedJobs to Sidekiq

Hey everyone!!!

Now that we have a smokin fast Redis instance going we are moving all of our background jobs from DelayedJob to Sidekiq! Click on the Issue linked below to learn more!

There are lots of details in there about why we are moving to Sidekiq, how we plan to do it, a guideline for helping out, and even a few example PRs to get you going. I think this is a GREAT opportunity for anyone looking to dip their feet in the open-source waters. Let me know if you have any questions!

Happing coding

GitHub logo Moving Jobs From DelayedJob to Sidekiq #5305

mstruve avatar
mstruve commented on Dec 30, 2019

Why We Are Moving To Sidekiq

Because DelayedJob relies on your database to process jobs, when you get a large volume of jobs it can be very slow. For this reason we are switching to Sidekiq to help ensure that as our job volume increases we have the ability to keep up with the new load. Also in DelayedJob, because it didnt handle lots of jobs well we have been ignoring any job failures in production which is not great when you are trying to ensure reliability. On Sidekiq we won't have to worry about allowing jobs to fail bc Sidekiq is built to handle a lot of jobs very quickly thanks to the help of Redis.

Sidekiq also has A LOT of very nice features and plugins that we can use as our job/worker flow becomes more complex. If you want to know more about why Sidekiq is a great background job tool checkout this blog post I wrote about moving to it from Resque.

Strategy For Moving Jobs

Same as we did for Redis keys, we are going to be moving jobs over one by one. When a job moves from DJ(DelayedJob) to Sidekiq we are going to be renaming it by ending its name with WorkerFor example: BustMultipleCachesJob => BustMultipleCachesWorkerThese new workers will be stored in a separate folder away form the jobs which will help us quickly evaluate what still needs to be done.

How You Can Help!

There are a lot of jobs that need to be moved which is why I would LOVE help from the community doing this! Grab a job, move it to Sidekiq and then open a PR with this issue tagged.

When Moving a Job

When you are moving a job there are 2 ways you can do it1. Create a new Worker class and delete the job all in the same PR: This is 100% fine for those jobs that do not run a lot. For example, if we run a job from the scheduler once a day, that is one we could roll over in a single PR.2. Create a new Worker, open a PR. Once that PR is merged, open a second PR to remove the old Job: This is what we need to do for jobs that are executed a lot. Think indexing or cache busting jobs. By merging the PRs separately we can ensure we don't strand any jobs that might be inflight when the new worker is created.

What queue should I put it in?Look at how often the job is executed and how important that job is. For example, jobs kicked off from the UI that are updating data we want do very quickly so the user gets the data they want. A scheduled job handing out badges, that is not as important and can be delayed a little bit so it can go on a low_priority queue. The Sidekiq queues we have are

:queues:  - ["default", 1]  - ["low_priority", 10]  - ["medium_priority", 100]  - ["high_priority", 1000]  - ["scheduler", 1000]  - ["mailers", 1000]

The numbers on the right indicate the queue importance. The higher the number the more important the queue is and the fast those jobs will be executed. The numbers are actually a ratio. In the event that every queue is full we will execute 1000 high_priority jobs for every 100 medium_priority, every 10 low_priority etc.

When you are moving jobs PLEASE feel free to take a look at the job itself and improve on either performance or how it is being executed. For example:

  • Add tests for the new worker even if the old job didn't have them.
  • Add early return statements when data is missing to avoid unnecessary work
  • Is the job silently failing? There may be times we don't want jobs to silently fail anymore
  • Are the arguments objects? We DO NOT want to be passing any object arguments, simple strings is our goal so take this time to change those to strings, ids, whatever.

Example PRs

Single PR Job Move: https://github.com/thepracticaldev/dev.to/pull/5269Multiple PR Job Move: PR 1 - https://github.com/thepracticaldev/dev.to/pull/5302

Jobs TODO

Let me know what you want to work on!!!

Articles:

  • [ ] bust_multiple_caches_job
  • [ ] detect_human_language_job.rb
  • [ ] score_calc_job.rb
  • [ ] update_analytics_job.rb
  • [ ] update_main_image_background_hex_job.rb

Audit

  • [ ] save_to_persistent_storage_job.rb

Badge Achievements

  • [ ] send_email_notification_job.rb

ChatChannels

  • [ ] index_job.rb

Classified

  • [ ] bust_cache_job.rb

Comments

  • [ ] bust_cache_job.rb
  • [ ] calculate_score_job.rb
  • [ ] create_first_reaction_job.rb
  • [ ] create_id_code_job.rb
  • [ ] send_email_notification_job.rb
  • [ ] touch_user_job.rb

Events

  • [ ] bust_cache_job.rb

Follows

  • [ ] create_chat_channel_job.rb
  • [ ] send_email_notification_job.rb
  • [ ] touch_follower_job.rb

Mentions

  • [ ] create_all_job.rb
  • [ ] send_email_notifications_job.rb

Notifications

  • [ ] mention_job.rb
  • [ ] new_badge_achievement_job.rb
  • [ ] new_reaction_job.rb
  • [ ] remove_all_job.rb
  • [ ] welcome_notification_job.rb
  • [ ] milestone_job.rb
  • [ ] new_comment_job.rb
  • [ ] notifiable_action_job.rb
  • [ ] tag_adjustment_notification_job.rb
  • [ ] moderation_notification_job.rb
  • [ ] new_follower_job.rb
  • [ ] remove_all_by_action_job.rb
  • [ ] update_job.rb

Orgs

  • [ ] bust_cache_job

Pages

  • [ ] bust_cache_job

Podcast Eps

  • [ ] bust_cache_job
  • [ ] create_job
  • [ ] update_reactable_job

Podcasts

  • [ ] bust_cache_job
  • [ ] get_episodes_job

Pro Memberships

  • [ ] popular_history_job

Reactions

  • [ ] bust_homepage_cache_job.rb
  • [ ] bust_reactable_cache_job.rb
  • [ ] create_job.rb
  • [ ] update_reactable_job.rb

Search

  • [ ] index_job
  • [ ] remove_from_index_job

Streams

  • [ ] twitch_webhook..._job

Tags

  • [ ] bust_cache_job

Users

  • [ ] bust_cache_job.rb
  • [ ] follow_job.rb
  • [ ] self_delete_job.rb
  • [ ] touch_job.rb
  • [ ] estimate_default_language_job.rb
  • [ ] resave_articles_job.rb
  • [ ] subscribe_to_mailchimp_newsletter_job.rb

Webhook

  • [ ] destroy_job
  • [ ] dispatch_event_job

Other

  • [ ] html_variant_trial_create_job.rb
  • [ ] html_variant_success_create_job.rb
  • [ ] export_content_job.rb
  • [ ] slack_bot_ping_job.rb
  • [ ] rss_reader_fetch_user_job.rb

Original Link: https://dev.to/devteam/call-for-contributions-move-all-delayedjobs-to-sidekiq-246k

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To