layer0
layer0 copied to clipboard
Environment Scaler should only terminate EC2 instances if they will be charged for another hour
AWS charges by the hour, rounding up for EC2 instances. It's more time/cost effective to keep an EC2 instance up for an hour than it is to delete/spin up a new instance within the same hour block.
With this is mind, the environment scaler should consider how long an EC2 instance has been running before terminating it. It should only terminate unused instances that are going to be charged for another hour before the scalar runs again - e.g. if the scalar runs every 5 minutes, it should only terminate the instance if it's at or past the 55 minute mark.