Use Reserved instance and autoscaling group

7.7k views Asked by At

I would like to know if it would possible to create an architecture with both reserved instance (RI) and auto-scaling group to serve web pages. The idea would be to have one RI serving 24/7 and launching on demand instances in an auto-scaling group when the CPU of the RI reach a threshold. The goal is to have a predictable cost (RI) and scale out solution with auto-scaling. Does it make sens ? Is it Possible ?

Thank you !

2

There are 2 answers

0
John Rotenstein On BEST ANSWER

A Reserved Instance on AWS is a billing concept and does not apply to a specific Amazon EC2 instance.

Each hour, the AWS billing system looks at all EC2 instances that have been running in a particular AWS account. It then compares them with any Reserved Instances that have been purchased. It compares the following attributes:

  • Instance Type (eg m3.large)
  • Operating System (eg Windows)
  • Availability Zone (eg us-west-2)

For each EC2 instance that matches a Reserved Instance, no cost applies. This is because the cost has already been paid as part of the Reserved Instance purchase.

The Reserved Instance applies regardless of whether the instance was launched through Auto Scaling.

Therefore, if you have purchased one Reserved Instance and your Auto Scaling group launches instances that match the Reserved Instance (Type, OS, AZ), then one of the instances in your Auto Scaling group will be "free" (or rather, pre-paid) each hour.

If your Auto Scaling group has a minimum of 1 and a maximum of 4, then there will always be at least one EC2 instance running, so you would receive the benefit of the Reserved Instance. Any instances above 1 will be charged normally. It is recommend that you use Reserved Instances for any instance that will be running continuously.

0
Akshay Pethani On

Updated as of April 2022

Quoting AWS Documentation

Reserved Instances are billed for every clock-hour during the term that you select, regardless of whether an instance is running. Each clock-hour starts on the hour (zero minutes and zero seconds past the hour) of a standard 24-hour clock. For example, 1:00:00 to 1:59:59 is one clock-hour. For more information about instance states, see Instance lifecycle.

A Reserved Instance billing benefit can be applied to a running instance on a per-second basis. Per-second billing is available for instances using an open-source Linux distribution, such as Amazon Linux and Ubuntu. Per-hour billing is used for commercial Linux distributions, such as Red Hat Enterprise Linux and SUSE Linux Enterprise Server.

A Reserved Instance billing benefit can apply to a maximum of 3600 seconds (one hour) of instance usage per clock-hour. You can run multiple instances concurrently, but can only receive the benefit of the Reserved Instance discount for a total of 3600 seconds per clock-hour; instance usage that exceeds 3600 seconds in a clock-hour is billed at the On-Demand rate.

For example, if you purchase one m4.xlarge Reserved Instance and run four m4.xlarge instances concurrently for one hour, one instance is charged at one hour of Reserved Instance usage and the other three instances are charged at three hours of On-Demand usage.

However, if you purchase one m4.xlarge Reserved Instance and run four m4.xlarge instances for 15 minutes (900 seconds) each within the same hour, the total running time for the instances is one hour, which results in one hour of Reserved Instance usage and 0 hours of On-Demand usage.

Reference:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-reserved-instances-application.html#hourly-billing