Josh Thompson     about     blog     ☕️ with josh

Sidekiq in Practice

Article Table of Contents

Working through Sidekiq in Practice.

Companion notes in a different repo for that course:

Similar to what I did for Noah Gibb’s Rebuilding Rails Course

draft notes, scratch pad, etc

Context: I joined a team at Homebot that deals with lots of background jobs, via Sidekiq and Redis. lots of jobs, every day. Many queueus. Time matters. Performance matters. So, here we go, deep dives, left and right.

I’m using this to store notes/code snippets for me, and others.

Tips on Sidekiq Queues ( #

I had to reference a few times, when I borked job enquing, and they all blew up hard.

Working through the above resource, for starters:

#  config/sidekiq-importance.yml
:concurrency: 5
  - foo
  - bar
  - baz
  - nevergonnagiveyouup

# app/jobs/priority_test_job.rb
class PriorityTest
  include Sidekiq::Worker

  def perform(*args) args "prioritytest: current time: #{}" 3 + 3 # difficult & computationally expensive operation
    sleep 3

start redis, then sidekiq:

bundle exec sidekiq -C ./config/sidekiq-importance.yml

in console:

require 'sidekiq/api'

queues = [:foo, :bar, :bazzzzz, :nevergonnagiveyouup]

50.times do |i|
  queues.each do |level|
    PriorityTest.perform_async(queue: level)
    p "#{i}: #{level}"

If jobs are stuck, might need:

require 'sidekiq/api'

Tried as I did, I never got the same results Phil did.

Sidekiq In Practice #

more notes to come soon!

💬 Comments

Post comment