In the RunInstance
API, you can specify the InstanceMarketOptionsRequest parameter to enable or disable the spot instance mode and configure the information about spot instances.
- Sync API: currently,
RunInstance
provides a one-time sync request API. This means that if the application fails because the inventory is insufficient or the requested price is lower than the market price, the RunInstance
API will immediately return a failure code and no longer apply for the spot instance again. - Fixed price: the fixed discount mode is used currently, so you must set the parameter to a value greater than or equal to the current market price. For more information on the market prices, see Spot Instance.
Sample scenario description
You have an instance in Guangzhou Zone 3, and the billing mode of the instance is pay-as-you-go on an hourly basis and in spot mode. The specific configurations of the billing mode are as follows:
- MaxPrice: 0.0923 USD/hour
- SpotInstanceType: one-time
- ImageId: img-pmqg1cw7
- InstanceType: S2.MEDIUM4 (Standard 2, 2-core, 4GB)
- InstanceCount: 1
Request parameters
https:
&Placement.Zone=ap-guangzhou-3
&InstanceChargeType=SPOTPAID
&InstanceMarketOptions.MarketType=spot
&InstanceMarketOptions.SpotOptions.MaxPrice=0.0923
&InstanceMarketOptions.SpotOptions.SpotInstanceType=one-time
&ImageId=img-pmqg1cw7
&InstanceType=S2.MEDIUM4
&InstanceCount=1
&<Common request parameters>
Response parameters
{
"Response": {
"InstanceIdSet": [
"ins-1vogaxgk"
],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
Was this page helpful?