Managing and reducing cloud costs is essential for any organisation using a public cloud provider such as AWS. There are several strategies for reducing your costs and each have their benefits such as EC2 and Compute savings plans, reserved instances and utilising spot instances. However, these strategies all keep your resources running and available during all hours of a week even if you’re not using them. The most effective strategy to reduce costs is to not use them at all. In our testing for some customer environments, automating the shutdown of resources outside of business hours saved them up to 75% on their AWS bill.
Environments such as development, QA, or testing, do not need to be active 24/7. By leveraging AWS Instance Scheduler which utilises Lambda and EventBridge scheduled triggers, you can automatically stop resources outside of business hours and start or redeploy them during work hours, saving substantial costs.
Automating Shutdowns with Instance Scheduler
By enabling instance scheduler, you can control when your development environment resources are available. For example, you can choose to schedule your EC2 instances, RDS databases, and other services to run between 9 AM and 5:30 PM on weekdays, leaving them off overnight and on the weekends. This instance schedule can be customised to your business requirements to allow once off changes to the schedule or to disable the schedule for a short period of time. This simple automation is easy to deploy, saves on cloud costs and covers all enabled services:
- Amazon EC2
- Amazon EC2 Auto Scaling groups
- Amazon RDS
- Amazon Aurora
- Amazon DocumentDB
- Amazon Neptune
Architecture diagram:
Cost Comparison: 24/7 vs Business Hours
Let’s review the potential savings by comparing the costs of running resources 24/7 versus limiting them to 8.5 hours a day during the weekdays (Monday through Friday). We need to keep in mind that the instance scheduler automation itself is not free, it costs approximately $13.50USD/Month to run but this in most cases it will pay for itself with stopping a single m5. large (or equivalent) instance.
- 24/7 Usage: Resources are running continuously, incurring costs for 24 hours, 7 days a week.
- Business Hours (8.5 Hours/Day, Weekdays Only): Resources are running only 42.5 hours per week, as opposed to 168 hours in a week for continuous operation.
Example: Amazon EC2 (m5.large instance)
- On-Demand Cost: $0.096 per hour in the us-east-1 region
- 24/7 Cost: $0.096/hour * 24 hours/day * 30 days = $69.12/month.
- Business Hours Cost: $0.096/hour * 8.5 hours/day * 5 days/week * 4.3 weeks/month = $17.48/month By only running the instance during business hours, you can save 56%, reducing the monthly cost from $69.12 to $17.48 – not including the $13.50 it will cost to enable the scheduler.
Example: Amazon RDS (db.m5.large instance)
- On-Demand Cost: $0.192 per hour in the us-east-1 region
- 24/7 Cost: $0.192/hour * 24 hours/day * 30 days = $138.24/month.
- Business Hours Cost: $0.192/hour * 8.5 hours/day * 5 days/week * 4.3 weeks/month = $34.96/month.
Here, running an RDS instance only during business hours results in similar savings, reducing costs by 75%, from $138.24 to $34.96 per month – not including the $13.50 it will cost to enable the scheduler.
Limitations:
One thing to keep in mind is that if you are stopping EC2 instances, you are still paying for the volumes attached to those instances so if you have large volumes attached to your EBS volumes, this automation does not reduce those costs seen in EC2-Other on your AWS bill. The solution cannot stop all AWS services since they’re not supported so in this case it is best to setup another pipeline to deploy those resources on a schedule and destroy them outside of hours. AWS Nuke is great for this - https://github.com/ekristen/aws-nuke
Conclusion
Automating the shutdown of AWS resources during off-hours with instance scheduler can lead to significant cost savings, especially for development and testing environments. This strategy not only optimizes cloud spending but also ensures your environments are available when you need them—without paying for unused compute power. By adjusting resources to run only when you need them, you can reduce costs by up to 75% and the more you shutdown, the more you save.
Download and enable the instance scheduler here: https://github.com/aws-solutions/instance-scheduler-on-aws/tree/main
Find out more: https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/