How I optimized cost of AWS Elastic Beanstalk by suspending machines during the off work period

Written by virtser | Published 2017/08/10
Tech Story Tags: aws | elastic-beanstalk | devops

TLDRvia the TL;DR App

If you are running few non production environments on AWS Elastic Beanstalk you were probably wondering how do you put its servers to sleep during the off work hours just to save few ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ?

There is a simple trick that AWS provide, but donโ€™t promote it for a reason. As a result not many know about it.ย ;)

All you need to do is to define two time periods in your environment Configuration -> Scaling -> Time-based scaling section.

One period with cron based time settings to Stop your EC2 environment machines and the other one to Start them.

Here is cron definition to reduce number of EC2 machines to zero at 17:00 UTC every working week dayโ€Šโ€”โ€Š0 17 * * 0,1,2,3,4

And a cron definition to increase number of EC2 machines to one at 05:00 UTC every working week dayโ€Šโ€”โ€Š0 5 * * 0,1,2,3,4

What it actually does is terminates and recreates the machines as AWS doesnโ€™t allow to suspend/pause EC2 machines.

If you can afford to run without Elastic Load Balancer it will save you even more as this trick wonโ€™t terminate the LB. ๐Ÿค‘


Published by HackerNoon on 2017/08/10