How to Create a Spot Amazon EC2 Instance

How to Create a Spot Amazon EC2 Instance

Amazon AWS cloud has three types of instance purchasing options:

  1. On-demand: the “ordinary” type of EC2 instance - Learn how to launch an on-demand instance.
  2. Reserved Instance : Paying a one-time upfront fee and save in hourly instance running costs.
  3. Spot instance:  A user can bid for the unused Amazon EC2 compute capacity and get the instance.

A spot instance helps to reduce the cost of the instance.Amazon EC2 has huge idle computing capacity and AWS allows using this idle computing power to launch an instance at a lesser price than an on-demand instance. The present guide demonstrates how to create a spot instance using the AWS supplied Linux AMI.

To use spot instances, the user places a spot instance request specifying the maximum price the user is willing to pay per hour per instance. If the maximum price of the bid is greater than the current spot price, the request is fulfilled and user’s instance runs until the user terminates it or the spot price increases above the maximum price. The instance can also be terminated when the bid price equals the market price, even when there is no increase in the market price. This can happen when the demand for the capacity rises, or when the supply fluctuates.

1. Enter your AWS Cloud UI Console and select the EC2 Service.

2. It launches the EC2 dashboard. The dashboard displays the current running instances, the available elastic IPs, volumes, snapshots and other details. Click on “Spot Instance”.

[Newvem analytics provides comprehensive visibility to your EC2 footprint with drill downs from a consolidated view to a detailed resource status report. Newvem continuously analyzes EC2 instance utilization patterns and provides a down-to-the-hour picture of your AWS EC2 consumption and usage. Learn More]

3. The spot instance console displays all existing spot instances. Click on the “Request Spot Instance” button.

4. The launch wizard asks the user to select the AMI. The AWS Launch screen provides multiple options to select the AMI. The user can select the AMIs provided by AWS (Standard OS). Select “My AMIs” to launch the instance from the user’s existing AMIs or select community AMIs to launch the instance from various providers (may or may not be authorized by AWS). The AWS Marketplace is used to launch the instance from the AWS online store. Click on the “Quick Start” tab and then select the Amazon Linux AMI.

5. Provide the instance details, such as the instance type and spot instance pricing information. The current price displays the price for the availability zone that the user has selected. If an availability zone is not specified, the current price displays the lowest price across all the availability zones. Provide the max price that the user is ready to pay for the spot instance. Also provide the other required details.

6. The other required parameters are given below. Provide their value and click on the “continue” button.

a. Max Price: This refers to the maximum price that the user is ready to pay for the spot instance. The user will be charged as per the current spot price only and not as per the max price bidding amount. The spot instance will be terminated when the current price increases more than the max price specified by the user.
b. Request Valid From and Request Valid Until: It defines the validity period for the spot request. The validity begins with Request Valid from the date and time and Request Valid Until, which specifies the length of time that the spot instance request will remain valid.
c. Persistent Request: This is used to define the request as one-time or persistent. By default, the spot request is one-time. A one-time request can only be fulfilled once. A persistent request is considered for fulfillment whenever there is no spot instance running for the same request.
d. Launch Group: It groups all the spot instance requests together in the same launch group. All requests in a launch group have their instances started and terminated together.

7. Provide the kernel ID and RAM disk ID.  If the user is using the IAM Role, select the role here. If the user wants to enable detailed monitoring, select the check box for the same. Click on “Continue” after providing the necessary data.

8. Provide the storage related information. Click on “Edit” to modify the volume size or type, otherwise click on “Continue”

9. For the security of the instance provide the key-pairs. Select the existing key-pair or create a new key-pair. Click on “Continue” after providing the existing key pair.

10. Select the security group. The security group provides the virtual firewall for the user’s instance. Open only the ports for the specific IPs, as per the user’s requirement. Click on “Continue”.

11. Review all the details and click on “Submit”. Verify the spot instance details.

12. AWS will launch the instance and provide the user confirmation for the spot instance request.

13. Go to the AWS Spot Instance console. Initially the status of the spot request will be in a “pending fulfillment” state.

14. Once the spot request is confirmed, the status will change to fulfilled. The console shows the spot instance related details, such as the price, and the status.

15. To launch a spot instance with the command line option, first setup the AWS EC2 CLI.

16. Run the command:

ec2-request-spot-instances to launch an spot instance.

ec2-request-spot-instances --price <max price>  <ami id> --key <key pair name>--group <group name> --instance-type m1.small --instance-count <count> --type <persistent or one type>

The actual output is shown below:

[Newvem analytics tracks your AWS cloud utilization:

  • Hourly Utilization Pattern Analysis 
  • Reserved Instances Decision Tool 
  • Resource Resizing Opportunities

Get Started For Free or Learn More]

Keywords: Amazon AWS elastic cloud services, Amazon EC2, Cloud Utilization, Amazon Web Services, AWS EC2, Amazon Machine Image, AWS AMI, Spot Instance, EC2 Dashboard, Request Instances Wizard

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations