Spot Instance Definition:
Spot Instances are spare EC2 compute capacity in the AWS Cloud available to you at savings of up to 90% off compared to On-Demand prices
My Confusions are:
How this Spare EC2 compute capacity is calculated
This Spare Capacity calculation is based on the Current Account OR Current Region OR Entire AWS Regions ?
Anybody with an AWS Account can launch an Amazon EC2 instance as a Spot Instance. If there is available capacity for the selected Instance Type and Availability Zone, the Spot Instance will be launched and you will be charged a price that is at the current Spot Price (normally much less than On-Demand prices).
However, AWS can stop/terminate that Spot Instance at any time when they need the capacity for customers who are using On-Demand instances. Therefore, the Spot Instance is not guaranteed to keep running.
You have no visibility into the available capacity or the likelihood that the Spot Instance will be stopped/terminated. If you want to maintain a level of capacity using Spot Instances, then you can use a Spot Fleet - Amazon Elastic Compute Cloud, which can automatically replace Spot Instances when they are stopped/terminated.
Related
While launching 2nd instance getting below error
you have requested more vcpu capacity than your current vcpu limit of 1 allows for the instance bucket that the specified instance type belongs to. please visit http://aws.amazon.com/contact-us/ec2-request to request an adjustment to this limit.
First, please note that the AWS Free Tier is a billing discount. It does not impact your ability to use any services. If the resources you use are within the limits imposed by the AWS Free Tier, you simply won't be charged for those resources. Thus, the AWS Free tier is not the cause of this error.
From On-Demand Instances - Amazon Elastic Compute Cloud:
There is a limit on the number of running On-Demand Instances per AWS account per Region. On-Demand Instance limits are managed in terms of the number of virtual central processing units (vCPUs) that your running On-Demand Instances are using, regardless of the instance type.
You did not tell us what Instance Type you are running, or attempted to run, but it sounds like you have exceeded this vCPU limit. This is more likely to happen with large or expensive instance types, or instance types that use GPU resources. You can view the limits in the Amazon EC2 management console by clicking Limits and then searching for vCPU.
If this is impacting your use of AWS, you can request an increase to these default limits.
See: Calculate a vCPU limit increase request for an Amazon EC2 On-Demand Instance
I have suddenly started getting no capacity available error while trying to create defined duration based spot instance in us-west-2. Other region works fine for me. I do not see any option to specify a price while trying to create this type of spot instance.
I do not have any other spot instance or any other ec2 instance running for me in this AZ as well.
My hypothesis is that there is no ec2 capacity available in whole us-west-2 region right now to create a spot instance. But I am finding that hard to believe. Is that correct?
Also I went through doc but it doesn't point out that by capacity it means for the whole of the aws us-west-2 region or just for my account
The no Spot capacity available error occurs when there isn't enough spare capacity to fulfill your Spot Instance or Spot Fleet request.
As capacity becomes available, Amazon EC2 fulfills requests in the following order:
Reserved Instances ->
On-Demand Instances ->
Spot Instances
The Spot request continues to automatically make the launch request until capacity becomes available. When capacity becomes available, Amazon EC2 fulfills the Spot request.
Its important to take a note about Lifecyle of spot request ->
Also according to lifecycle of spot request
If one or more request constraints are valid but can't be met yet, or if there is not enough capacity, the request goes into a holding state waiting for the constraints to be met. The request options affect the likelihood of the request being fulfilled. For example, if you specify a maximum price below the current Spot price, your request stays in a holding state until the Spot price goes below your maximum price. If you specify an Availability Zone group, the request stays in a holding state until the Availability Zone constraint is met.
In the event of an outage of one of the Availability Zones, there is a chance that the spare EC2 capacity available for Spot Instance requests in other Availability Zones can be affected
I have a fresh AWS account with Reserved Capacity of 15 EC2 instances of the same instance type in the same region primarily intended for EMR.
If I spawn a EMR cluster with 10 instances for 15 days and scale it up to 20 instances for the remaining 15 days, will I get charged $0?
If not, how will the final bill for EC2 for the month be calculated?
The reason why I am confused is that based on my understanding EC2 charges based on capacity consumed (in instance hours) and not on actual instances allocated. Since I'm reserving 15 instances worth of capacity, I would expect it to cost me a total of $0 since my overall monthly average consumption is worth 15 instances.
The Reserved EC2 Pricing documentation and most of the AWS price-calculation related material on the internet don't mention the use-case of dynamic scaling of instances in accounts with reserved capacity.
Reserved instances are applied to running instances in real time, not averaged over any longer period of time. They are baseline, not average.
For example, if you own three Reserved Instances with the same instance attributes and region (or Availability Zone if applicable), the billing system checks each hour to see how many total instances you have running that match those parameters. If it is three or less, you will be charged the Reserved Instance rate for each matching instance running that hour. If more than three are running, you will be charged the On-Demand rate for the additional instances.
https://aws.amazon.com/ec2/pricing/reserved-instances/buyer/
At any instant in time when you lack enough reserved capacity to cover your running workload, you're billed for the excess.
Please let me aware about the charges of ssd while all ec2 instances is reserved, then why $0.10 per GB-month is deducting?
I have reserved c4.2xlarge and m4.xlarge instances but still charges are continuous deducted from bill the heavy charge only for this below:
$0.10 per GB-month of General Purpose SSD (gp2) provisioned storage - US East (Northern Virginia)
For the saving of cost what can i do more? like above things are not happening.
It appears that your situation is:
You have purchase Reserved Instances for a c4.2xlarge and a m4.xlarge instance
You are seeing charges for Amazon Elastic Block Store (EBS) SSD storage
This is normal behaviour.
A Reserved Instance is a pre-payment (either monthly or annual) for Amazon EC2 capacity. When running an EC2 instance that matches the Reserved Instances, there is no hourly charge because the Reserved Instance has pre-paid for that usage.
However, the cost of Amazon EBS is not included with a Reserved Instance. The cost of an EBS volume is additional to your Amazon EC2 costs. This applies for all types of EC2 instances, whether or not they are being charged as Reserved Instances and whether they are Running or Stopped.
Some options to further save money:
Only create EBS disk volumes as large as necessary. You always pay for the full size of the volume, so unused space still costs money. You can always modify the volume to make it bigger in future.
Turn off instances when they are not required, at least for any instances not covered by your Reserved Instance purchases
If you are running additional instances, consider using Spot Pricing (but instances might be terminated if the spot price rises higher than your bid price)
I am trying to create ec2 spot instances using boto3 api, so far I am able to get the spot instance history price, spin up a spot instance, etc.
But I don't know how to get the price we are paying for spot instance using boto api.
anyone know how to do this ?
Thanks
Update: See: Spot Instance Interruptions - Amazon Elastic Compute Cloud
Old answer:
When launching a spot instance under Amazon EC2, you specify a maximum hourly price, known as a bid. This is the maximum price that will be charged for the instance.
When the instance is launched, and on each hourly anniversary of the instance being in a running state, the instance will be charged at the then-current spot price.
If an instance is terminated due to the spot price rising above the bid price, then there is no charge for the partial hour where the instance was terminated. However, if the user terminates a spot instance, the partial hour will be charged.
Therefore, "the price we are paying for spot instance" is the price at the start of each hour. It is calculated at the time that the charge takes place.
To obtain the price charged for a spot instance, use the Spot Instance Data Feed that provides a data feed that describes your Spot Instance usage and pricing. This data feed is sent to an Amazon S3 bucket that you specify when you subscribe to the data feed. It is updated hourly.