The project is in a healthy, maintained state
auto scaler of sidekiq worker deploymented to aws ecs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

> 1, < 2
> 5, < 8
 Project Readme

SidekiqEcsScaler

Auto scaler of Sidekiq worker deploymented to AWS ECS.

Only supported when deploying Sidekiq workers to AWS ECS Fargate (1.14.0+)

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-ecs-scaler'

And then execute:

$ bundle install

Usage

Create Worker Class

# frozen_string_literal: true

class SidekiqEcsScaleWorker
  include Sidekiq::Worker

  # @return [void]
  def perform
    SidekiqEcsScaler::Client.update_desired_count(
      max_count: 3
    )
  end
end

Options

logger: logger, default is Sidekiq.logger
queue_name: queue to monitor latency, default is "default"
min_count: minimum number of tasks, default is 1
max_count: maximum number of tasks, default is 1
step_count: steps number in the desired count range, default is 1
max_latency: maximum latency(seconds), default is 3600
ecs_client: custom ECS Client, default is Aws::ECS::Client.new

With Sidekiq Scheduler

When using sidekiq-scheduler, schedule the scale by setting as follows.

# sidekiq.yml
# example

:schedule:
  SidekiqEcsScaleWorker:
    cron: "0 */15 * * * *"
    # It is safe to set this queue to have a higher priority than the monitored queue.
    queue: scheduler

About AWS IAM Policy

The task role of ECS task that runs Sidekiq workers requires the following permissions:

  • ecs:DescribeTasks
  • ecs:DescribeServices
  • ecs:UpdateService

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq-ecs-scaler.

License

The gem is available as open source under the terms of the MIT License.