使用预留实例和自动缩放组

Use Reserved instance and autoscaling group

我想知道是否可以创建一个同时具有预留实例 (RI) 和自动缩放组的架构来为网页提供服务。 这个想法是让一个 RI 提供 24/7 服务,并在 RI 的 CPU 达到阈值时在自动缩放组中启动按需实例。 目标是拥有可预测的成本 (RI) 并通过自动缩放向外扩展解决方案。 它有意义吗?可能吗 ?

谢谢!

A​​WS 上的预留实例 是一个计费概念,不适用于特定 Amazon EC2 实例。

每小时,AWS 计费系统都会查看特定 AWS 账户中 运行 的所有 EC2 实例。然后将它们与已购买的任何预留实例进行比较。它比较以下属性:

  • 实例类型(例如m3.large)
  • 操作系统(例如Windows)
  • 可用区(例如 us-west-2)

对于与预留实例匹配的每个 EC2 实例,不收取任何费用。这是因为费用已作为预留实例购买的一部分支付。

无论实例是否通过 Auto Scaling 启动,预留实例都适用。

因此,如果您购买了一个预留实例并且您的 Auto Scaling 组启动了与预留实例(类型,OS,AZ)匹配的实例,那么您的 Auto Scaling 组中的一个实例将是"free"(或更确切地说,预付费)每小时。

如果您的 Auto Scaling 组最少有 1 个,最多有 4 个,那么总会有至少一个 EC2 实例 运行,因此您将获得预留实例的好处。任何超过 1 的实例都将正常收费。 建议您对任何将 运行 连续使用的实例使用预留实例。

更新于 2022 年 4 月

引用 AWS 文档

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.

参考:

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