DEV Community

Cover image for Managing Spot Instances
Komal-J-Prabhakar
Komal-J-Prabhakar

Posted on • Edited on

Managing Spot Instances

According to a recent survey, the worldwide public cloud computing market has been projected to reach $495 billion by end of 2022.

The present-day cloud technologies turn out to be a vital factor in driving innovation and business growth. However, jumping onto the bandwagon of cloud users without planning for cloud cost optimization makes it an expensive affair.

Proceeding further, we will be discussing one such method of cloud cost reduction. That is the use of spot instances. The major public cloud service providers Amazon Web Services (AWS), Microsoft Azure, and Google Cloud all offer spot instances. But let’s understand “what are spot instances?”

What are Spot instances?

Spot instances are the unused cloud computing capacity that is available at steep discounts compared to the on-demand instances and reserved instances.
The cloud service pricing model is divided into the following three categories:

  • On-demand Instances - This is the pay-as-you-go model, where you pay in terms of computing power used per hour or second. Here you get the flexibility of increasing or decreasing the resources as per your operational requirements. There are no long-term commitments or upfront charges.
  • Reserved Instances - These costs slightly lesser than on-demand instances. They are what you consider for a longer period. Say 3 years or 5 years, this is when your entire cloud infrastructure runs on a daily basis. These are the long-term commitments where you get to pay a bigger sum upfront. They cost 40-50% lesser than on-demand instances, the pricing also depends on the cloud service provider.
  • Spot Instances - As discussed earlier these are offered at steep discounts, i.e., even lesser than reserved instances. But there’s a catch, these do not have any fixed prices, and customers/users have to bid on the unused capacity of the cloud provider’s data center. Now, these prices vary as they are adjusted across the availability zones based on market demand and the biggest consideration is that - this spare capacity can be taken away almost instantaneously!

Spot Instances on AWS

The Spot instances in AWS use the unutilized EC2 (Elastic Compute Cloud) instance facilitating them in optimizing their cloud costs. These unused EC2 instances have a variable price in the AWS Spot Market depending on the supply and demand of these instances.
The pricing of spot instances on AWS is done on an hourly basis and is known as the spot price.
Considering the demand and availability of spot instances, AWS determines the auction price (spot price) for each instance type in their respective availability zone.

The Working of AWS Spot Instances

Working of AWS Spot Instance

  • To begin with, the user needs to create a spot instance request. The request includes the following data - quantity of instances, the type of spot instances, the availability zone, and the maximum bid.
  • When the maximum bid exceeds the auction price, with all conditions of the spot instance request met, Amazon launches the unused EC2 instances. However, if the bid doesn’t exceed, Amazon waits till all the conditions are met to process the request, or the user may cancel the request.
  • But the work doesn’t end here, the spot instances launched would stay only up to the time the maximum bid of the user exceeds the spot price. The very moment when the prices change, the allotted instances get terminated. Or it can even get terminated if the requested capacity is unavailable. A point to be noted is that the user can start or stop an instance manually. Furthermore, if an instance gets terminated the user can open a new request, and again if all conditions are met the EC2 instances are launched.

[ A Good Read: Guide to Creating Spot Instance Request on AWS ]

How do AWS Spot Instances help Businesses?

Cost Saving

The biggest benefit of using spot instances is quite obvious, the cost-benefit. It costs less than the on-demand and reserved instances. In this particular case study on Lenskart, an effective 80% reduction in overall cloud costs is achieved by leveraging Spot Instances.

Flexibility for Experimentation and Growth

Voost specializes in developing a digital asset management platform for professional cryptocurrency traders and businesses. Their creation ‘Pastel’ ( SaaS Platform ) required connecting with global exchanges to collect large volumes of data. This enables users to view their distributed crypto assets in one place without visiting the exchange. However, being a startup with limited resources, building this infrastructure on on-demand instances made it an expensive affair. This is where they thought of leveraging spot instances, which saved them around 90% in cost over on-demand instances. (reference)

Summing up the benefits from the above case:

  • No more waiting for approvals or incurring any higher costs while giving shape to your ideas. We can act quicker on our ideas, and test them directly with customers without any delays.
  • Spot instances are an effective solution, when not sure whether you need extra resources for certain experimental projects.
  • It gives a choice to businesses for investing in what is critical, and what is required, preventing wastage.

Improved DevOps Productivity

The principles of DevOps promise faster deliverability of products and services. This holds true when the right amount of automation is implemented in the CI/CD pipeline.
It helps in streamlining the DevOps lifecycle by reducing the friction surrounding the testing and release processes, enabling a smoother assembly line.

Challenges of Spot Instances

Transient Nature

The spot instances in AWS are with us till the time -

  • The current price exceeds our maximum bid of the spot instances
  • Or the requested capacity becomes unavailable The moment either of the conditions becomes true, the spot instances are terminated immediately. Any applications working on them get interrupted, and we possibly lose a lot of data in the process.

The possible solution is to automate these processes through a platform, whereby all the operations continuing on the AWS spot instances are saved and the very moment spot instances are withdrawn, the platform automatically switches the work to on-demand instances. Thereby balancing the costs and business processes seamlessly.

Multi-Cloud Adoption

Enterprises today are adopting multi-cloud services. It is obvious that different cloud services have different methods of allotting spot instances. Although we are diversifying our resources, at times it becomes a cumbersome process to shuffle the workload among all these variations.
Bringing automation to this is going to solve half of our woes. A hybrid cloud deployment platform that creates a secure virtual environment, and helps us in building a safe passage for our product following the compliances simplifies the product journey.

Choosing the right combination of Instances

The right combination of instances is the blend of spot instances, on-demand instances, and reserved instances for optimal application performance. To be able to know, what part of an application’s service can be compromised (that can be made to work in spot instances), and which parts are critical. For this information, we need to have a good understanding of what our customers want, and this can be achieved by storing data in dashboards format.
A practical solution will be an intuitive platform that stores all metrics in a proper dashboard fashion, and accordingly ensures and allots different instances for optimal resource utilization. Now, businesses are no more busy looking after infrastructure requirements, they can direct their focus toward the core business operations.

Conclusion

The market is very competitive. Businesses are facing steep competition in the form of innovation, agility, and better customer service. This is where spot instances help in filling these competitive gaps. Choosing the right jobs like data analysis, background processing, batch jobs, and other optional tasks can not only bring down our costs but successfully supplement the overall performance of an application.
The foundational pillars of a successful business are proper cost optimization, faster deliverability, and better customer experience. Bringing in this modularity requires a lot of human hours but when considered through an intuitive platform, complexities are reduced to a great extent. Businesses are in for a long marathon and if the right decisions are taken in terms of implementing automation, we are enhancing its lifespan by manifolds.

Top comments (0)