Auto scaler of Sidekiq worker deploymented to AWS ECS.
Only supported when deploying Sidekiq workers to AWS ECS Fargate (1.14.0+)
Add this line to your application's Gemfile:
gem 'sidekiq-ecs-scaler'
And then execute:
$ bundle install
# 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
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
The task role of ECS task that runs Sidekiq workers requires the following permissions:
ecs:DescribeTasks
ecs:DescribeServices
ecs:UpdateService
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq-ecs-scaler.
The gem is available as open source under the terms of the MIT License.