kermit 6fd784933f Scaling system for AWS Engine Workers | 2 years ago | |
---|---|---|
.. | ||
config | 2 years ago | |
lib | 2 years ago | |
spec | 2 years ago | |
.gitignore | 2 years ago | |
.ruby-version | 2 years ago | |
.travis.yml | 2 years ago | |
Gemfile | 2 years ago | |
Gemfile.lock | 2 years ago | |
README.md | 2 years ago | |
Rakefile | 2 years ago |
AWS CloudWatch metrics for Sidekiq for Autoscaling an Elastic Beanstalk Sidekiq environment based off of the queue size
Copy .env
to .env.production
and fill in .env.production
with the real configuration values
bundle exec foreman run -e .env.production rake metrics:update
Check the AWS console to see your custom metric
You can monitor your Sidekiq instances on AWS for free using Heroku Scheduler
heroku config:set
rake metrics:update
or rake metrics:schedule_update
every 10 minutesNotes:
To get finer granularity on Heroku you can run a job every minute with Heroku Scheduler by creating 10 jobs spaced 1 minute apart. POST
to scheduler using the following command:
curl 'https://scheduler.heroku.com/jobs' --data 'command=rake+metrics%3Aupdate&dyno_size=11&every=10&at=9'
at
is the minute you want to start the job and takes the values 0
to 9
. You'll also need to post your cookie. To get the full curl
command I used Chrome Develper Tools and captured a request.
Scheduling and update with rake metrics:schedule_update
also works but the worker process will sleep on a free Heroku dyno.
Elastic Beanstalk doesn't let you configure alarms for custom metrics for autoscaling out of the box. However you can manually change the Autoscaling group to add custom Scaling Policies.
90
, Lower threshold 45
EC2 -> Autoscaling -> Autoscaling Groups
heroku config:set AWS_CLOUDWATCH_DIMENSION_VALUE=<auto-scaling-group-name>
CloudWatch -> Custom Metrics
. One should be for sidekiq-worker-overload
and the other should be for sidekiq-worker-underload
EC2 -> Autoscaling -> Autoscaling Groups -> Scaling Policies
add two new policies. One for aws-eb-autoscale-up
and the other for aws-eb-autoscale-down
. Select the appropriate alarm created in step 5 for each policy.Note if you ever rebuild or terminate your environment, Elastic Beanstalk will create a new autoscaling group and CloudWatch put the CloudWatch alarms in it. You'll need to repeat steps. 3-8 above.