0.0
No commit activity in last 3 years
No release in over 3 years
This library provides CLI interface for starting multiple copies of Sidekiq in parallel, typically to take advantage of multi-core systems. By default it starts N - 1 processes, where N is the number of cores on the current system. Sidekiq Cluster is controlled with CLI flags that appear before `--` (double dash), while any arguments that follow double dash are passed to each Sidekiq process. The exception is the `-P pidfile`, which clustering script passes to each sidekiq process individually.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.5.0
>= 0

Runtime

 Project Readme

WARNING: this GEM is not fully finished.

Please use sidekiq-pool instead.

Build Status Maintainability Test Coverage

Sidekiq Cluster

This is a tiny gem that allows starting sidekiq using multiple processes. It is originally based on the wonderful Honebadger Cluster Script.

Features:

  • It does not depend on any particular version of sidekiq, as long as the CLI class of Sidekiq remains named the same.

  • It does not attempt to replicate Sidekiq's command line options. Script itself can be controlled with its own CLI options preceeding the double dash --. Options to Sidekiq are expected after the double dash.

  • You can specify max number of processes and max total RAM used by this cluster (expressed as a percentage of total). If one of the Sidekiq processes exceeeds it, it is automatically restarted.

Usage

The easiest way to use Sidekiq Cluster is to add it to your Gemfile:

gem 'sidekiq-cluster', require: false

Run bundle, and then start Sidekiq cluster like so (this starts exactly two Sidekiq Processes):

# this starts sidekiq with default options
$ bundle exec sidekiq-cluster -N 2

# this starts sidekiq with custom options
$ bundle exec sidekiq-cluster -N 2 -- -r $(pwd) -q default,10 -q high,100

Command Line Options

Then try running it with --help:

sidekiq-cluster -h

USAGE
     sidekiq-cluster [options] -- [sidekiq-options]

EXAMPLES
    $ cd rails_app
    $ bundle exec sidekiq-cluster -N 2 -- -c 10 -q default,12 -L log/sidekiq.log
 
SIDEKIQ CLUSTER OPTIONS
    -n, --name=NAME                  the name of this cluster, used when 
                                     when running multiple clusters
                                      
    -P, --pidfile=FILE               Pidfile prefix, 
                                     eg "/var/www/shared/config/sidekiq.pid"
                                      
    -L, --logfile=FILE               Logfile for the cluster script
                                      
    -M, --max-memory=PERCENT         Maximum percent RAM that this
                                     cluster should not exceed. Defaults to 80%.
                                      
    -N, --num-processes=NUM          Number of processes to start,
                                     defaults to number of cores - 1
                                      
    -q, --quiet                      Do not log to STDOUT
    -d, --debug                      Print debugging info before starting sidekiqs
    -h, --help                       this help


Examples

$ cd rails-app
$ echo "gem 'sidekiq-cluster'" >> Gemfile
$ bundle install
$ bundle exec sidekiq-cluster \        # these arguments are for sidekiq-cluster:
    --pidfile /var/pids/sidekiq.pid \  
    --name default \
    --max-memory 90 \
    --logfile /var/log/sidekiq-cluster.log \
    --num-processes 2 \  
    -- \                               # these arguments are for sidekiq:
    -L /var/log/sidekiq.log -c 10 -e production -q default,10 -q critical,20

Contributing to sidekiq-cluster

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2018 Konstantin Gredeskoul. See LICENSE.txt for further details.