Amazon Web Services (AWS) offers infrastructure on demand so that customers can control their resource capacity and pay only for what they consume. One simple method to reduce Amazon Elastic Cloud Compute (Amazon EC2) costs is to stop Amazon EC2 instances that are not in use, and then start those instances again when their capacity is needed.

The EC2 Scheduler is a simple AWS-provided solution that enables customers to easily configure custom start and stop schedules for their Amazon EC2 instances. The solution is easy to deploy and can help reduce operational costs for both development and production environments. For customers who leave all of their Amazon EC2 instances running 24 hours a day, this solution can result in up to 70% cost savings for those instances that are only necessary during regular business hours.

This webpage provides best practices for implementing automated actions on resources, as well as an overview of the EC2 Scheduler design and functionality.  

ec2-scheduler-savings

When running infrastructure on the cloud, automate the monitoring and management of resources whenever possible and be sure to stop resources when they are not in use. Automated actions are more reliable than manual processes, helping to maximize savings and identify trends in overprovisioning. For optimal efficiency and cost savings, consider these best practices when implementing an automated start-stop solution:

  • Plan for exceptions and account for different schedules and usage scenarios. A one-size-fits-all approach is seldom realistic, even within the same department. Choose a flexible and customizable tool that can accommodate your needs.
  • Implement a resource-identification system, such as tags for Amazon EC2 instances. This helps to ensure that automated actions are targeted to the correct resource, and also allows for easier filtering, modification, and troubleshooting according to categories that you define.
  • Grant least-privilege access to individuals or systems that perform automated actions on resources.  

AWS offers a simple solution that allows you to create automatic start and stop schedules for your Amazon EC2 instances. The diagram below presents the components and functionality you can build using the EC2 Scheduler implementation guide and accompanying AWS CloudFormation template.

ec2-scheduler-architecture
  1. During initial deployment, define the default start and stop parameters and the interval for the EC2 Scheduler to run. These values are stored in Amazon Dynamo DB, and can be overridden or modified as necessary.
  2. Apply a custom resource tag to Amazon EC2 instances that should receive EC2 Scheduler actions.
  3. Modify individual instance tags to customize EC2 Scheduler actions, if necessary.
  4. The solution's recurring AWS Lambda function automatically starts and stops appropriately tagged Amazon EC2 instances.
  5. Review the solution's custom Amazon CloudWatch metric to see a history of EC2 Scheduler actions.
Deploy Solution
Implementation Guide

What you'll accomplish:

Deploy the EC2 Scheduler using AWS CloudFormation. The CloudFormation template will automatically launch and configure the components necessary to automatically start and stop Amazon EC2 instances in all AWS Regions of your account.

Configure multiple start and stop schedules by either deploying multiple EC2 Schedulers or modifying individual resource tags. The EC2 Scheduler solution gives you the flexibility to automatically manage multiple schedules as necessary.

Review EC2 Scheduler metrics to better assess your EC2 capacity and usage, and to calculate your cost savings.

What you'll need before starting:

An AWS account: You will need an AWS account to begin provisioning resources. Sign up for AWS.

Skill level: This solution is intended for IT infrastructure and DevOps professionals who have practical experience with automation and architecting on the AWS cloud.

Q: What default start and stop times does the EC2 Scheduler use?

The customer defines default parameters during initial deployment of the solution's AWS CloudFormation template. You can choose to deploy the solution again if you wish to run multiple deployments with different settings. You can also modify an individual instance's resource tag to specify custom parameters that will override the default settings.

Q: Can I create multiple start-stop schedules for a single instance?

Yes. Each deployment of the solution runs a separate AWS Lambda function that looks for a specific resource tag. You can deploy the EC2 Scheduler multiple times and then apply multiple tags (that each correlate with a specific deployment) to a single instance. See the implementation guide for detailed instructions.

Q: At what interval(s) can the EC2 Scheduler start and stop my instances?

You can create weekly schedules for the EC2 Scheduler, and can configure it to run on specific days of the week or all days.

Q: Do I configure start and stop times in my local time zone?

No. You must define all start and stop times in UTC. If you want to set unique start and stop times for groups of instances in different time zones, you can either specify custom parameters in their resource tags or use multiple deployments of the EC2 Scheduler (each with different default parameters).

Q: How much will it cost to run the EC2 Scheduler?

You are responsible for the cost of the AWS services used while running this reference deployment. The majority of the solution's cost is incurred from the custom Amazon CloudWatch metric, if you choose to enable it. For full pricing details, see the implementation guide.

Q: Can I deploy the EC2 Scheduler in any AWS Region?

Customers can deploy the EC2 Scheduler AWS CloudFormation template only in AWS Regions where AWS Lambda is available (see AWS service offerings by region). However, once deployed, the solution's Lambda function can apply actions to Amazon EC2 instances in any AWS Region.

Need more resources to get started with AWS? Visit the Getting Started Resource Center to find tutorials, projects and videos to get started with AWS.

Tell us what you think