buildkite / elastic-ci-stack-for-aws

An auto-scaling cluster of build agents running in your own AWS VPC
https://buildkite.com/docs/quickstart/elastic-ci-stack-aws
MIT License
417 stars 275 forks source link

Add support for scheduled scaling up/down #262

Open BRMatt opened 7 years ago

BRMatt commented 7 years ago

As a team that is almost entirely based in a single timezone, we tend to work a regular 9-5 schedule.

We have one stack for building docker images, and one for running tests. The former uses on-demand instances with min=1, to ensure we have a warm cache throughout the day. The latter uses spot instances and has min=0.

Given we don't really work outside of our 9-5, it would be nice to be able to set the docker builders to min=0 when we're not using them (i.e. evenings and weekends), and min=1 at 8 am on every weekday. This would significantly cut the cost of our ci infrastructure.

If we did need to run a build outside of these times then the regular cloudwatch alarms would be able to spin up a docker builder.

holmesjr commented 7 years ago

I'm going to +1 this. I'd love to have a parameter-configurable autoscaling up and down time for similar reasons. I'm happy to add it to the template as a PR if you folks are happy to have it in the stack.

lox commented 7 years ago

Yup, would happily accept a PR.

dalberto commented 7 years ago

Scheduled Scaling might be a straightforward way to approach this. It supports cron expressions, so it should be possible to express non-trivial recurrence rules. I intend to explore this option with the ASG the stack creates.

toolmantim commented 7 years ago

I'm imagining a two new parameter groups "Scheduled Scale Up" and "Scheduled Scale Down" each with two fields: "recurrence rule" and "desired capacity".

And the presence of those sets up the two recurring scheduled scaling rules for you.

xiaket commented 5 years ago

I took a look at our current template today and tried to add the scheduled actions to it. The problem is, we've already have 47 parameters in the template, and I reckon we need to add at least 4 more parameters into the template. I'm a bit hesitant to do that because that will put the number of params close to the upper limit(60).

So for now, my approach is to add another stack and add the scheduled actions in that stack.

However, @lox if you are not too worried about adding another 4 parameters into the current stack, I'm more than happy to provide a PR.

theonlysinjin commented 3 years ago

Reviving a super old issue but you could attach this post-fact. Things may have changed much since you last tried but you can add this on your own as it just requires the ASG name. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-scheduledaction.html