本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Amazon OpenSearch Service 中的預留執行個體
相較於標準隨需執行個體,Amazon OpenSearch Service 中的預留執行個體 (RI) 提供大幅折扣。執行個體本身均相同;RI 是套用到您的帳戶中隨需執行個體的一種計費折扣。對於可預測使用量的長效應用程式,RI 可隨時間的累積產生可觀的節省成果。
OpenSearch Service RI 需要一年或三年期預留執行個體,並且提供三種對折扣費率有相當影響的付款選項:
-
不預付 - 無須任何預付款。在期限內,按折扣後的每小時費率支付每個小時的費用。
-
部分預付 - 您需要預付部分費用,並且在期限內,按折扣後的每小時費率支付每個小時的費用。
-
全部預付 - 您支付整個預付款的費用。您不是按照小時費率支付費用。
一般來說,較大的預付款表示較大的折扣。您無法取消預留執行個體 - 當您預留時,表示您承諾支付整個期限 - 且預付款項不可退還。
RI 並不靈活;它們只適用於您保留的確切執行個體類型。例如,八個 c5.2xlarge.search
執行個體保留不適用於十六個 c5.xlarge.search
執行個體或四個 c5.4xlarge.search
執行個體。如需完整詳細資訊,請參閱 Amazon OpenSearch Service 定價
購買預留執行個體 (主控台)
主控台可讓您檢視現有的預留執行個體和購買新的執行個體。
購買預訂
-
前往 https://aws.amazon.com
,然後選擇 Sign In to the Console (登入主控台)。 -
在 Analytics (分析) 下,選擇 Amazon OpenSearch Service。
-
在導覽窗格中,選擇 Reserved Instance Leases (預留執行個體租用)。
在此頁面上,您可以檢視現有的預訂。如果您有許多預訂,您可以篩選以更輕鬆地識別和檢視特定預訂。
提示
若您沒有看到 Reserved Instance Leases (預留執行個體租用) 連結,請在 AWS 區域中建立網域。
-
選擇 Order Reserved Instance (預訂預留執行個體)。
-
提供唯一且描述性名稱。
-
選擇執行個體類型和執行個體數量。如需準則,請參閱調整 Amazon OpenSearch 服務域。
-
選擇期限長度和付款選項。仔細檢閱付款詳細資訊。
-
選擇 Next (下一步)。
-
仔細檢閱購買摘要。購買預留執行個體無法退款。
-
選擇 Order (預訂)。
購買預留執行個體 (AWS CLI)
AWS CLI 具有檢視產品、購買預訂及檢視預訂的命令。以下命令和範例回應顯示某個指定 AWS 區域的產品:
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" } ] }
如需每個傳回值的詳細說明,請參閱下表。
欄位 | 描述 |
---|---|
FixedPrice |
預訂的預付費用。 |
ReservedInstanceOfferingId |
方案 ID。如果您想要預訂產品,請備註此值。 |
RecurringCharges |
預訂的小時費率。 |
UsagePrice |
傳統欄位。對於 OpenSearch Service,此值始終為 0。 |
PaymentOption |
無預付、部分預付或全部預付。 |
Duration |
期限長度,以秒為單位:
|
InstanceType |
預訂的執行個體類型。如需分配給每個執行個體類型的硬體資源的資訊,請參閱 Amazon OpenSearch Service 定價 |
CurrencyCode |
用於 FixedPrice 和 RecurringChargeAmount 的貨幣。 |
這個下一個範例購買預訂:
aws opensearch purchase-reserved-instance-offering --reserved-instance-offering-id
1a2a3a4a5-1a2a-3a4a-5a6a-1a2a3a4a5a6a
--reservation-namemy-reservation
--instance-count 3 --regionus-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 epoch 時間,以秒數計算,從 1970 年 1 月 1 日 UTC 午夜起已經過的秒數。例如,1522872571 epoch 時間是 2018 年 4 月 4 日 20:09:31 UTC。您可以使用線上轉換器。
若要進一步了解前述範例中使用的命令,請參閱 AWS CLI 命令參考。
購買預留執行個體 (AWS 開發套件)
AWS SDK (Android 和 iOS SDK 除外) 支援 Amazon OpenSearch Service API 參考中定義的所有操作,包括下列操作:
-
DescribeReservedInstanceOfferings
-
PurchaseReservedInstanceOffering
-
DescribeReservedInstances
此範例指令碼使用來自 AWS SDK for Python (Boto3) 的 OpenSearchServiceinstance_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)
如需安裝與使用 AWS 開發套件的詳細資訊,請參閱 AWS 軟體開發套件
檢查成本
Cost Explorer 是一個免費的工具,可讓您用於檢視過去 13 個月的支出費用資料。分析這項資料可協助您識別趨勢,並了解 RI 是否符合您的使用案例。如果您已經有 RI,可以透過https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/groupdata.html購買選項和顯示分攤成本分類,進而針對隨需執行個體比較該項支出和您的支出。您也可以設定用量預算,確保充分利用您的預留額度。如需詳細資訊,請參閱 AWS Billing 使用者指南中的使用 Cost Explorer 分析您的成本。