Being street smart with AWS Spot Instances !!
Tags: aws, ec2, optimization, cost
Published: 2023-10-02 05:47:22

 Well, all of us know that there is AWS Spot Instances available at much lower prices risking consistent availability. But do everyone knows that there is a Spot Placement score which keeps us informed about the likely availability of the instance type, region & AZ of our needs?

###Welcome to another key area of cost optimization series !!###

_**What are AWS Spot Instances?**_
AWS Instance types that EC2 instances that are unused and free. Utilizing AWS Spot Instances is smart choice for jobs or tasks that can be interrupted and/or started on based on EC2 Spot Instance request availability. This gives us great edge for saving costs for workloads that can be risked for interruptions

_**When to use AWS Spot Instances?**_
My best tip would be to go in for, "All things non-production" which are "stateless & flexible workloads"

_**How is AWS Spot Instance available?**_
Make an AWS Spot Instance Request from the AWS account and once there is free resource/EC2 of the requested EC2 Instance Type & Configuration, then the capacity is released or else request will be made until there is availability

_**Cost Benefit - AWS Spot Instances !!**_
AWS Spot Instances are 90% less compared to their on-demand prices.

_**What to look out for in terms of limitations ?**_
i) Availability - Raising request doesn't guarantee EC2 availability immediately
ii) If on-demand rises for the instance type which is provisioned as Spot, there will be an interruption notification and rebalance recommendations

Now, that sets the background for anyone on Spot Instances but how to you plan or get best bet on getting it? Use **AWS Spot Placement Score**

**AWS Spot Placement Score**
Feature in AWS that helps in selecting the right Region & AZ for placing the Spot Instances request. Basically, Instance Type or vCPU or Memory can be defined and AWS gives a score rating from 1 to 10 against each Region & AZ(optional) where 10 giving more surety on getting a successful spot instance(s) in that Region and/or AZ and 1 being "No or less chances of getting a spot instances"

Let us see how it works. Go to EC2 Console View -> Spot Requests -> Spot Placement Score

_**Step 1**_

i) Define the required no. of instances or no of vCPU(s) or amount of memory 
ii) In this assessment, I have given '2' instances of type 'c6g.12xlarge'


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oprj60rvx5rug81495o3.png)

_**Step 2**_

i) Next, is region and/or AZ selection
ii) Now the score in all the activated region(s) in my account gets a '3' which means the instance type 'c6g.12xlarge' availability on Spot cannot be guaranteed 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyte12sbvh2tafoe2wpt.png)


_**Whats Next**_

Now, I can go with below options
1) Go for some other equivalent instance type and check their placement score. If better, use that EC2 instance type
2) Again, getting good placement score, say 10, doesn't give any assurance of getting the instance type available immediately
3) Score generated needs to be refreshed or 'Load New Placement Score' as & when the discussions more forward 
4) Right time to use this 'AWS Spot Instance Placement Score' is just before buying or placing "AWS Spot Instance Request"

Save More !!