Convox Tips: Disabling racks on evenings and weekends

Using the AWS Console

Make sure to adjust the cron schedule to fit your requirements — and make sure you convert the times to UTC
Note: the default Max for a convox rack is 100, and we only want to scale up Monday — Friday

Using the AWS CLI

{
"AutoScalingGroupName": "convox-<rackname>-Instances-<id>",
"ScheduledActionName": "ScaleDown",
"Recurrence": "0 0 * * *",
"MinSize": 0,
"MaxSize": 0,
"DesiredCapacity": 0
}
{
"AutoScalingGroupName": "convox-<rackname>-Instances-<id>",
"ScheduledActionName": "ScaleUp",
"Recurrence": "0 12 * * MON-FRI",
"MinSize": 0,
"MaxSize": 0,
"DesiredCapacity": 0
}
$ aws autoscaling put-scheduled-update-group-action --cli-input-json file://down.json
$ aws autoscaling put-scheduled-update-group-action --cli-input-json file://up.json

Using Terraform

variable "asg_name" {} variable "scale_up_capacity" {  
type = "string"
default = "4"
}
variable "scale_down_recurrence" {
type = "string"
default = "45 0,6 * * *" # UTC
}
variable "scale_up_recurrence" {
type = "string"
default = "15 12 * * MON-FRI" # UTC
}
variable "min_size" {
type = "string"
default = "1"
}
variable "max_size" {
type = "string"
default = "100"
}
resource "aws_autoscaling_schedule" "scale_down" {
autoscaling_group_name = "${var.asg_name}"
scheduled_action_name = "ScaleDown"
recurrence = "${var.scale_down_recurrence}"
desired_capacity = 0
}
resource "aws_autoscaling_schedule" "scale_up" {
autoscaling_group_name = "${var.asg_name}"
scheduled_action_name = "ScaleUp"
recurrence = "${var.scale_up_recurrence}"
desired_capacity = "${var.scale_up_capacity}"
min_size = "${var.min_size}"
max_size = "${var.max_size}"
}

Final Notes

  • Sometimes, a dev needs to do some work late in the evening, or on a weekend. We’ve created Jenkins jobs to allow our devs to turn the environment on/off as needed. We also added a second scale down time late at night in case the developer forgot to turn the rack back off.
  • It usually takes between 5–10 minutes for a rack to spin up and start all of the app processes.
  • We’re saving over $200/m by scaling our dev racks down during off hours. This will only grow as we increase instance sizes, counts and number of developer racks.

--

--

--

Senior SRE @getsentry

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Warkentin

Michael Warkentin

Senior SRE @getsentry

More from Medium

It works! How to painlessly migrate on-premises VMware workload to AWS?

This week in the HeadInTheCloud Series — Microservices!

aws_cloudwatch

What is DevOps:The Bakery analogy.