Skip to content

ASG: Inconsistent Handling of Decimal Places in Spot Instance Prices

0

An attempt to launch a new EC2 spot instance from launch template fails when the spot instance price is formatted with three decimal places followed by zeros (e.g., "0.000700"). However, the price format with three significant digits followed by zeros (e.g., "0.007000") is accepted without issues. This inconsistency in decimal place validation is causing confusion and preventing successful instance launches. During launch template creation, there are no errors or warnings related to this.

Expected Behavior The EC2 spot instance should launch successfully regardless of the decimal place format, as long as the numerical value is valid. If value is not considered correct, it should give a warning/error message.

Current Behavior The EC2 launch process from an auto scaling group fails when the price is formatted with three decimal places followed by zeros (e.g., "0.000700"), but succeeds when formatted with three significant digits followed by zeros (e.g., "0.007000").

aws autoscaling describe-scaling-activities --auto-scaling-group-name "spot-t3-nano-asg" --region=ap-south-1
{
    "Activities": [
        {
            "ActivityId": "6ae64ee1-d80e-4e0a-bbd3-e5bc7c522af6",
            "AutoScalingGroupName": "spot-t3-nano-asg",
            "Description": "Launching a new EC2 instance.  Status Reason: Value (0.000700) for parameter price is invalid. \"0.000700\" is an invalid spot instance price. Launching EC2 instance failed.",
            "Cause": "At 2024-12-12T01:22:40Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.",
            "StartTime": "2024-12-12T01:22:42.195000+00:00",
            "EndTime": "2024-12-12T01:22:42+00:00",
            "StatusCode": "Failed",
            "StatusMessage": "Value (0.000700) for parameter price is invalid. \"0.000700\" is an invalid spot instance price. Launching EC2 instance failed.",
            "Progress": 100,
            "Details": "{\"Subnet ID\":\"subnet-059e739f688e00000\",\"Availability Zone\":\"ap-south-1a\"}",
            "AutoScalingGroupARN": "arn:aws:autoscaling:ap-south-1:559050245391:autoScalingGroup:ac27ab00-3fa7-4d0f-a12b-9753a8500000:autoScalingGroupName/spot-t3-nano-asg"
        }

Reproduction Steps Create a launch template. Specify the spot instance with max price as "0.000100". Scale desired or max capacity in the auto scaling group to attempt to launch a new EC2 spot instance. Observe the failure message indicating that the price is invalid with aws autoscaling describe-scaling-activities or from console > ec2> auto scaling groups > select group > acivities.

To make it work: Change the spot instance max price to "0.001000" from the launch template. Update ASG. Observe that the instance launches successfully from ASG.

Question: Is this an API bug?

Thanks!

asked 2 years ago199 views

2 Answers
0

Hi,

This is because you can't currently set a value lower than 0.001 for the Max Price. I'm guessing the extra 0's added at the end are just being ignored. Keep in mind that this value could change in the future, but for now you'll need to set a value of 0.001 or higher.

Also something to note is that this parameter is rarely used anymore. It was designed back when Spot had Bidding, but that went away in 2017, and now Spot prices can never be higher than the OnDemand price, and are changed gradually based on long term trends vs bidding for capacity with other AWS customers: https://aws.amazon.com/blogs/compute/new-amazon-ec2-spot-pricing/

EXPERT

answered 2 years ago

  • Hi, I don't really understand your answer.

    1- Currently it is not possible to set a value lower than 0.001, but it should. That's the point of my issue here.

    2- The reason why this is necessary: there are spot instances with lower price than $0.001 and in some use cases this is critical (e.g. we don't want to pay more than X money for X instance types; so if price rise above that Max Price, cancel the spot request).

    Obviously, spot prices can never be higher than On Demand.. but if the Spot Prices are currently based on bidding/demand trends, it is very important to have precision in the MaxPrice parameter because if we are setting a Max Price much more higher than average price then prices could rise, affecting (increasing) even the average price..

  • 1- Correct, its not currently possible. I've put a feature request in for this, but as of now $0.001 is the lowest you can set it.
    2- Just to be clear, there is no more bidding. Prices do not change moment to moment as you bid with other users (back when bidding existed though, the price could theoretically go above OnDemand). And prices now change gradually over time. Are you setting price per instance, or price per vCPU (or other weighted pricing)? If setting price per Instance, the cheapest OnDemand instance in us-east-1 is $0.0042, and is currently ~2x the lower limit for MaxPrice. Depending on your setup, requesting capacity based on Instances vs Weighted Capacity may be an option to help with the current MaxPrice limits

  • Hi, 1- Great, thanks. 2- Yes, I understand the bidding stuff. But following what you pointed on your first message, what I'm trying to say is that if spot prices are based on the market demand, then MaxPrice does have an impact in the average market price. Users' max prices directly impact how aggressively the market responds to demand changes. High max prices increase competition and push up the average spot price, while low max prices create opportunities for lower averages, especially in periods of reduced demand. The interplay between users' max price strategies creates the dynamic nature of spot markets.

    Thats why its important to have a precise limit, specially because there are regions with instance types with prices below the 0.000X value.

0

Based on the information provided, this behavior does appear to be inconsistent and could potentially be considered an API bug or at least an inconsistency in the way AWS handles decimal places for spot instance prices.

The fact that the price format "0.000700" is rejected while "0.007000" is accepted, despite both representing valid numerical values, suggests an issue with the input validation or parsing of spot instance prices in the EC2 Auto Scaling API.

This inconsistency in handling decimal places is not expected behavior. Typically, AWS services should be able to handle various decimal representations of the same numerical value, especially when it comes to pricing information.

The error message "Value (0.000700) for parameter price is invalid. '0.000700' is an invalid spot instance price" further indicates that there might be an overly strict or improperly implemented validation check in the API.

Given that this issue prevents successful instance launches and causes confusion for users, it would be advisable to report this to AWS support. They can investigate further and potentially address it as a bug in their API handling of spot instance prices.

In the meantime, as a workaround, users should format their spot instance prices using three significant digits followed by zeros (e.g., "0.007000") to avoid this issue when creating launch templates or configuring Auto Scaling groups with spot instances.
Sources
Keeping Unhealthy Auto Scaling (ASG) Instances (Detaching Unhealthy ASG Instance instead of Terminating) | AWS re:Post
Keeping Unhealthy Auto Scaling (ASG) Instances (Detaching Unhealthy ASG Instance instead of Terminating) | AWS re:Post

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.