[autoscaler] Don't scale up if a build is almost done

It would be cool to let the autoscaler decide to create a new agent or wait on an existing one, depending on time left on the current builds. IE: On average, your builds take 40 minutes. There’s 1 at the 35 minute mark, and a new build comes in. Don’t scale up. Instead wait for that one to finish. Useful when using AWS spot instances for example.

how much money would such a feature save in AWS hosting bills per month?

I’m not sure how much to be honest, but it should save some.

Spot instances are billed by the hour, I guess it would depend on your build average time and number of builds and how often they come in. I honestly don’t have numbers to back this up.

If your builds take 20 minutes, you’ll want that spot instance hanging around until the full hour is completed, which you can already accomplish with DRONE_POOL_MIN_AGE. Paying for another hour when you could’ve waited 2 minutes and reuse that one doesn’t sound very effective.

You could also save some more by having DRONE_POOL_MIN_AGE work differently when DRONE_AMAZON_MARKET_TYPE=spot. Right now, if it is set to something like DRONE_POOL_MIN_AGE=55m, and you run say, 5 15 minute builds on it, you’d be on a 75 minute mark. DRONE_POOL_MIN_AGE goes into action and kills it, but you already payed for that second hour.

The reason I ask is because at some point we see diminishing returns. The cost to code this feature could vastly exceed the amount of money it actually saves. One must demonstrate the cost to implement such micro-optimizations will result in a significant cost savings for the end-user, which is not evident at the moment.

Keep in mind that the autoscaler is designed for teams spending thousands of dollars per month on servers. We want to help reduce big server bills. We are less interested in reducing the size of server bills that are already quite low.

So with that being said, I am fully open to optimizations if we can demonstrate they will provide significant monthly cost savings.

@msaizar actually spot instances are also billed by the second. https://aws.amazon.com/ec2/pricing/