Last Updated: February 25, 2016
·
1.073K
· stympy

Sidekiq worker utilization

Here's a one-liner for measuring your sidekiq worker utilization (active threads / total possible threads). E.g., if you have 4 sidekiq processes working, each with a concurrency of 20, you'd see something like this with pgrep:

... [1 of 20 busy]
... [0 of 20 busy]
... [0 of 20 busy]
... [0 of 20 busy]    

In this case, we have 1.25% utilization, which the following ruby one-liner will print as "1.25":

pgrep -lf busy | ruby -e "working, total = ARGF.each_with_object([0.0, 0.0]) {|l, p| l.scan(/(\d+) of (\d+)/).first.each_with_index {|n, i| p[i] += n.to_f } }; puts (working / total) * 100"