Jean Meyer
Jean Meyer

Reputation: 409

Sidekiq: Count the number of available threads

I'd like to count from the Rails console the total number of available Sidekiq threads/processors.

threads != workers

Sidekiq::Workers.size doesn't work

Upvotes: 2

Views: 1814

Answers (1)

Mike Perham
Mike Perham

Reputation: 22208

You are looking for Sidekiq::ProcessSet#each.

https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/api.rb#L719

Sidekiq::ProcessSet.new.each do |pro| 
  puts "I have #{pro['concurrency'] - pro['busy']} threads free"
end

Upvotes: 4

Related Questions