Level 200: EC2 Scheduling at Scale

Authors

  • Enrico Bonaccorsi, Principal Technical Account Manager.
  • Francesc Sala, Principal Technical Account Manager.

Contributors

  • Carlos Perez, Geo Solutions Architect, AWS Well-Architected.
  • Ben Mergen, Sr Cost Lead SA WA.

Well-Architected Best Practices

This lab helps you to exercise the following AWS Well-Architected Best Practices in your Cost Optimization process:

  • COST06-BP03 - Select resource type, size, and number automatically based on metrics
  • COST09-BP01 - Perform an analysis on the workload demand
  • COST09-BP03 - Supply resources dynamically

Introduction

In this lab, we will leverage AWS resource tags and the AWS Instance Scheduler solution to optimize the cost of idle workloads at scale.

Implementing an effective tagging strategy is fundamental for setting up your environment for cost optimization. Among many advantages, such as attributing your costs and usage throughout your organization, tagging also allows you to categorize and distinguish resources between your development, test and production environments. This can help you to effectively identify workloads and implement mechanisms to supply resources dynamically based on the environment.

The Instance Scheduler solution used in this lab allows you to follow a time-based approach for making resources available only at times when they are actually needed. In addition, the solution leverages AWS resource tags and AWS Lambda for automating the starting and stopping of Amazon EC2 and Amazon RDS instances, which can result in up to 70% savings of operational costs.

You will learn about best practices for cost optimization and the implementation of mechanisms, aided by automation at scale, that empower application owners to follow actionable tasks for cost optimization.

References: This lab focuses in one of the modules from the re:Invent 2022 workshop SUP304 - Continuous Cost and Sustainability Optimization

Goals

  • Deploy and verify the configuration of the AWS Instance Scheduler solution
  • Leverage the AWS Instance Scheduler to implement a schedule with the following requirement:
    • EC2 instances with the tag key “walab-environment” and value “dev” should be in stopped state outside of the Seattle business hours

Prerequisites

  • An AWS account that you are able to use for testing. The account should not be used for production purposes.
  • An IAM user in your AWS account who has either AdministratorAccess or PowerUserAccess (with full IAM access).

Costs

  • Instance Scheduler Cost: As of January 2023, the cost for running the Instance Scheduler solution with default settings in the US East (N. Virginia) Region is approximately 9.90USD per month in AWS Lambda charges, or less if you have Lambda free tier monthly usage credit.
  • Sample workload instances Cost: Five on-demand t3.nano EC2 instances will be launched as part of a sample fleet. The cost per t3.nano instance is $0.0052 per hour. For 5 instances running, for the whole month, the cost would be 18.98USD.
  • After completion of the lab, in section 4, you will find steps to delete the resources created. The cost figures mentioned above are only in case this lab’s related resources are left running for the whole month.

NOTE: You will be billed for any applicable AWS resources used if you complete this lab that are not covered in the AWS Free Tier.

Steps: