For building and testing applications, cloud providers’ pay-as-you-go pricing models offer tremendous flexibility. But leaving applications to run 24/7 can be costly. This is especially true for larger enterprises, where the costs of applications are often not billed individually, making it harder to spot unnecessary expenditure. As an AWS partner, we’ve identified how to manage unneeded EC2 (Amazon Elastic Compute Cloud) instances and save costs by shutting them down overnight, explained here step-by-step.
The AWS Solutions Library includes an Instance Scheduler: a serverless tool for automatically starting and stopping EC2 and RDS instances. You can use the tool to define multiple schedules for different use cases. For example, you could have schedules for:
In our customers’ environments, the Instance Scheduler is managed centrally, enabling applications to consume it without operational overhead. The Solution is very user friendly, as the end-user only needs to tag the instances with the appropriate schedule tag.
AWS Instance Scheduler
The AWS Instance Scheduler is a scalable solution, making it equally suitable for large AWS Organizations with multiple accounts as well as single account environments. Large organizations using the tool require the following adjustments:
Now that you have adjusted the Instance Scheduler, you must tag the EC2s with the proper schedule. In organizations with hundreds of accounts, this is not straightforward. You may find that account owners do not tag their instances consistently or at all. To address this, we deployed the following automation for a client:
Auto-tagging of EC2 instances
Now that all new instances are tagged automatically, the next challenge are the existing EC2s. These are the ones really driving the costs, so they need to be included in the night-time saving. We solved this problem for our enterprise customer by informing all project account owners that we would centrally tag instances in non-production accounts on a specific date.
On the due day, we invoked a central Lambda similar to the Auto-Tag Lambda. It assumed a role in each project account and tagged existing instances with the same filtering mechanism mentioned. An opt-out schedule was also defined and communicated beforehand to project account owners in case they needed to run their instances 24/7.
The Instance Scheduler automates starting and stopping instances on AWS. With some modifications, it is also possible to use the tool in big AWS organizations to shut down instances overnight and realize measurable cost savings. This solution provides lower cost savings in environments with a high number of autoscaling groups or the previously mentioned AWS services (EKS/ECS, Beanstalk, Cloud9). With our enterprise customer example, although several Autoscaling Groups were in use, we reduced the costs of EC2 instances by 15%.
If you enjoyed this blog post, please stay tuned for future blogs to learn about other ways to optimize your cloud costs.