Scheduling at scale

With its default configuration, the Instance Scheduler solution will apply the “seattle-office-hours” schedule to all EC2 Instances that have a tag with Key=“Schedule” and Value=“seattle-office-hours”. This is the only configuration that needs to be done to stop the instance outside Seattle Office hours. A Cloud Center of Excellence (CCOE) team could configure this at scale using Tag Editor feature of AWS Resource Groups with batch of 500 instances, or with custom automation (i.e. with AWS SSM). End users and application owners could do the same for their resources. In the following steps we will use Resource Groups and Tag Editor to configure the tag Schedule=seattle-office-hours to all DEV instances in this account/region.

Apply the seattle-office-hours schedule to DEV EC2 instances at scale

  1. Open the Resource Groups and Tag Editor Console using this link:

  2. Click on Tag Editor on the left side panel:

section3_1_scheduleatscale

  1. For Resource Types, select AWS::EC2::Instance:

section3_2_scheduleatscale

  1. For the Tags, we need to search based on two tags.

    Add a tag named walab-environment with value dev. Click on the “Add” button.

    section3_3_1_scheduleatscale

    Add another tag named aws:autoscaling:groupName with value (not tagged). Click on the “Add” button.

    section3_3_2_scheduleatscale

    By adding the above, we are excluding any EC2 instances that has a tag named aws:autoscaling:groupName (those launched by EC2 Auto Scaling Groups). We need to exclude any instances that are part of an Auto Scaling Group (ASG) to avoid the Instance Scheduler solution entering into a loop where it will stop instances that an ASG would immediately replace with new ones.

    Now that both tag definitions were added to the search criteria, click on the “Search resources” button:

    section3_3_3_scheduleatscale

  2. Scroll down. You should now see the list of dev instances that are present in this account, select them all and click on “Manage Tags of selected resources”

section3_4_scheduleatscale

  1. Scroll down until you see the “Edit tags of all selected resources” section. Click on the “Add tag” button and add new tag key named Schedule with value seattle-office-hours. Then, click on “Review and apply tag changes”. (Note that tags are case sensitive, be aware of any trailing blank spaces)

section3_5_scheduleatscale

  1. You will now see the confirmation window, go ahead and accept the changes:

section3_6_scheduleatscale

  1. Verify that the tag is now present on the EC2 instances, going to EC2 and selecting all instances with the tag “Schedule=seattle-office-hours”:

section3_7_scheduleatscale

  1. You have now configured all DEV EC2 instances in this account and region to be turned off outside of the Seattle office hours. No other action is needed. The scheduler will now take care of stopping eligible EC2 instances outside office hours and starting them back again during office hours.

section3_8_scheduleatscale

Congratulations!

You have completed the last section of this lab!

In this lab you could see how to benefit from the Instance Scheduler on AWS solution to increase the elasticity of your AWS infrastructure and follow a time-based supply approach for cost optimization. As keeping instances in a stopped state when they are not needed will decrease your costs considerably.

With the default seattle-office-hours schedule used in this lab, we have reduced by 76% the costs of the DEV workloads. Using the scheduler-cli you could define your own schedules, and instruct the end-users to apply such schedules on their DEV environments. This would shift the responsibility around elasticity for EC2 workloads to the application owners and the end users. You can then measure savings using AWS Cost Explorer or the Cost and Usage Report (CUR). Cost Explorer and CUR billing data are delayed by ~48hours, so after ~2days you should be able to visualize the savings.

Reducing cost by 50 - 70%

To get a better idea with another example on how a time-based supply approach can help in optimizing cost, in below image, you can see how the Cost Explorer report would look like when stopping instances at a large scale, but only during weekends.

For this example, a larger fleet of EC2 instances was used, accounting to ~22K USD/day across all instances. Notice that after using Instance Scheduler for stopping a subset of those instances, the cost was reduced to ~15K USD/day during weekends, which equates to a total of ~55K USD/month savings.

scheduler_costexplorer

Click on Next Step and follow the steps to clean up the resources created in this lab.