Amazon OpenSearch Service 中的预留实例 - 亚马逊 OpenSearch 服务
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Amazon OpenSearch Service 中的预留实例

与标准按需实例相比,Amazon OpenSearch Service 预留实例 (RI) 提供大幅折扣。实例本身是相同的;RI 只是对账户中的按需实例所应用的账单折扣。对于使用可预测、长期存在的应用程序,随着时间的推移,RI 可以提供可观的节省时间。

OpenSearch Service RI 需要一年期或三年期并且具有影响折扣率的三个付款选项:

  • 无费用预付 – 无需支付任何预付费用。期限内,每小时按已折扣的每小时费率收费。

  • 预付部分费用 – 提前支付部分费用,期限内,每小时按已折扣的每小时费率收费。

  • 预付全费 – 提前支付全部费用。期限内,不再按每小时费率收费。

一般而言,预付款越多意味着折扣越大。无法取消预留实例—预留它们时,您承诺支付整个期限的费用并且预付款不可退款。

RI 不灵活;它们只适用于您预留的确切实例类型。例如,8 个 c5.2xlarge.search 实例预留不适用于 16 个 c5.xlarge.search 实例或 4 个 c5.4xlarge.search 实例。有关完整详情,请参阅 Amazon OpenSearch Service 定价常见问题

购买预留实例(控制台)

利用控制台,可查看现有预留实例和购买新的预留实例。

购买预留实例
  1. 转至 https://aws.amazon.com,然后选择 Sign In to the Console (登录控制台)

  2. Analytics 下,选择 Amazon OpenSearch Service

  3. 从导航窗格中选择 Reserved Instance Leases(预留实例租赁)

    在此页面上,可以查看现有预留。如果具有许多预留,可以筛选它们以更轻松地识别和查看特定预留。

    提示

    如果您未看到 Reserved Instance Leases(预留实例租赁)链接,请在 Amazon Web Services 区域 中创建域

  4. 选择 Order Reserved Instance(对预留实例排序)

  5. 提供唯一的描述性名称。

  6. 选择实例类型和实例数量。有关操作指南,请参阅 调整亚马逊 OpenSearch 服务域名的大小

  7. 选择期限长度和付款选项。仔细阅读付款详细信息。

  8. 选择 Next(下一步)。

  9. 仔细阅读购买摘要。购买的预留实例不可退款。

  10. 选择排序

购买预留实例 (Amazon CLI)

Amazon CLI 具有查看产品、购买预留实例和查看预留实例的命令。以下命令和示例响应显示指定 Amazon Web Services 区域 的产品:

aws opensearch describe-reserved-instance-offerings --region us-east-1 { "ReservedInstanceOfferings": [ { "FixedPrice": x, "ReservedInstanceOfferingId": "1a2a3a4a5-1a2a-3a4a-5a6a-1a2a3a4a5a6a", "RecurringCharges": [ { "RecurringChargeAmount": y, "RecurringChargeFrequency": "Hourly" } ], "UsagePrice": 0.0, "PaymentOption": "PARTIAL_UPFRONT", "Duration": 31536000, "InstanceType": "m4.2xlarge.search", "CurrencyCode": "USD" } ] }

有关每个返回值的说明,请参阅下表。

Field 描述
FixedPrice 预留的前期成本。
ReservedInstanceOfferingId 产品 ID。如果要预留产品,则记下此值。
RecurringCharges 预留的小时费率。
UsagePrice 旧字段。对于 OpenSearch Service,此值始终为 0。
PaymentOption 无预付费用、预付部分费用或预付全费。
Duration 期限长度 (秒):
  • 31536000 秒为一年。

  • 94608000 秒为三年。

InstanceType 预留的实例类型。有关分配给每个实例类型的硬件资源的信息,请参阅 Amazon OpenSearch Service 定价
CurrencyCode FixedPriceRecurringChargeAmount 的货币。

下一个示例购买预留实例:

aws opensearch purchase-reserved-instance-offering --reserved-instance-offering-id 1a2a3a4a5-1a2a-3a4a-5a6a-1a2a3a4a5a6a --reservation-name my-reservation --instance-count 3 --region us-east-1 { "ReservationName": "my-reservation", "ReservedInstanceId": "9a8a7a6a-5a4a-3a2a-1a0a-9a8a7a6a5a4a" }

最后,您可以使用以下示例列出指定区域中的预留:

aws opensearch describe-reserved-instances --region us-east-1 { "ReservedInstances": [ { "FixedPrice": x, "ReservedInstanceOfferingId": "1a2a3a4a5-1a2a-3a4a-5a6a-1a2a3a4a5a6a", "ReservationName": "my-reservation", "PaymentOption": "PARTIAL_UPFRONT", "UsagePrice": 0.0, "ReservedInstanceId": "9a8a7a6a-5a4a-3a2a-1a0a-9a8a7a6a5a4a", "RecurringCharges": [ { "RecurringChargeAmount": y, "RecurringChargeFrequency": "Hourly" } ], "State": "payment-pending", "StartTime": 1522872571.229, "InstanceCount": 3, "Duration": 31536000, "InstanceType": "m4.2xlarge.search", "CurrencyCode": "USD" } ] }
注意

StartTime 为 Unix 纪元时间,其是自 1970 年 1 月 1 日午夜 (UTC) 以来经历的秒数。例如,1522872571 纪元时间为 2018 年 4 月 4 日 20:09:31 (UTC)。可以使用在线转换器。

要了解有关上述示例中所用命令的更多信息,请参阅 Amazon CLI 命令引用

购买预留实例 (Amazon SDK)

Amazon SDK(除 Android 和 iOS SDK 之外)支持在 Amazon OpenSearch Service API 参考中定义的所有操作,包括:

  • DescribeReservedInstanceOfferings

  • PurchaseReservedInstanceOffering

  • DescribeReservedInstances

此示例脚本使用 Amazon SDK for Python (Boto3) 中的 OpenSearchService 低级别 Python 客户端购买预留实例。您必须为 instance_type 提供一个值。

import boto3 from botocore.config import Config # Build the client using the default credential configuration. # You can use the CLI and run 'aws configure' to set access key, secret # key, and default region. my_config = Config( # Optionally lets you specify a region other than your default. region_name='us-east-1' ) client = boto3.client('opensearch', config=my_config) instance_type = '' # e.g. m4.2xlarge.search def describe_RI_offerings(client): """Gets the Reserved Instance offerings for this account""" response = client.describe_reserved_instance_offerings() offerings = (response['ReservedInstanceOfferings']) return offerings def check_instance(offering): """Returns True if instance type is the one you specified above""" if offering['InstanceType'] == instance_type: return True return False def get_instance_id(): """Iterates through the available offerings to find the ID of the one you specified""" instance_type_iterator = filter( check_instance, describe_RI_offerings(client)) offering = list(instance_type_iterator) id = offering[0]['ReservedInstanceOfferingId'] return id def purchase_RI_offering(client): """Purchase Reserved Instances""" response = client.purchase_reserved_instance_offering( ReservedInstanceOfferingId = get_instance_id(), ReservationName = 'my-reservation', InstanceCount = 1 ) print('Purchased reserved instance offering of type ' + instance_type) print(response) def main(): """Purchase Reserved Instances""" purchase_RI_offering(client)

有关安装和使用 Amazon SDK 的更多信息,请参阅 Amazon 软件开发工具包

调查费用

Cost Explorer 是一款免费工具,可用于查看过去 13 个月的支出数据。分析此数据有助于确定趋势和了解 RI 是否适合使用案例。如果已有 RI,则可分组 (按 Purchase Option (购买选项)) 并显示摊销费用以将此支出与按需实例的支出进行比较。还可设置使用预算以确保您可以充分利用预留。有关更多信息,请参阅 Amazon Billing 用户指南中的使用 Cost Explorer 分析费用