UXPin Engineering

The Full-Stack UX Design Platform • www.uxpin.com

Follow publication

Why are we using AWS Spot instances?

--

Probably quite a few of you use AWS with On-demand or reserved instances, but you are still afraid of the spot instances. Is it because the spot market is so unpredictable? What would you say if I told you that you can use spots without fear?

What is the spot market?

You can learn more about it on the AWS website:

Simply speaking, Amazon has a lot of unused resources which you can freely bid. If your bid is higher than a current price per hour — you can use that EC2 instance, if not — it’ll be terminated.

Where do we use spots at UXPin?

Everywhere! Ok, maybe it’s an overstatement, but in fact, we’re using spot instances for all stateless instances (web servers, CI/CD, cron workers etc). That’s right — each of our web servers is based on the spot instances and they are not a cause of any downtimes! Currently we use regular EC2/RDS instances only for queues, caches and DBs.

How do we actually use them?

Earlier we used Autoscaling groups with few launch configurations (one per spot type per AZ) with spots. However, that configuration was hard to manage and because of many problems (have you ever tried to adjust capacity in that solution?:)) we used it only for staging environment.

And then we found spotinst.com.
Long story short, it’s SaaS product which helps you optimize your cloud (AWS/ GCE/ Azure) bill. They’re using machine learning to predict spot prices. And those predictions are more than acceptable :-) If a current spot price per hour is higher than an on-demand price then you’ll receive an on-demand instance. But if price drops, you’ll be switched to the spot instance. It’s really simple but effective mechanism.

However, the crucial fact here is that while creating Elastigroups (equivalent of the autoscaling groups), you choose minimum 2 types of spot instances. Thanks to that, in case of any fluctuations of the price of the given type, you’re automatically transferred to the other type, or another AZ. Only when you use up these possibilities, you get an on-demand instance.

c4.2xlarge price history

As you can see in the screenshot, spot prices can differ considerably within a single day. A regular price of C4.2xlarge is $0.498 per hour, but on 11/8 between 11:30 PM and 4:30 AM its cost increased to $5.3 comparing to the regular price below $0.15. When price increased, a part of our infrastructure was automatically switched to on-demand instances or to another spot type.

Right now we don’t experience any problems with spots. We have been using them on the production environment since March and managing the Elastigroups turned out to be a pure pleasure. Earlier if we changed AMI (and we’re changing it frequently), we had to create a new launch configuration each time, and then we needed to change autoscaling group and do a rolling update (we didn’t use cloud formation). In Spotinst we simply chain AMI ID then we only need to press “Rolling update” button and we are all set.

So, if you want to start using spot instances on the production — request a demo of the Spotinst. You won’t regret it!

Answering my initial question — why are we using AWS spot instances? Because they’re cheap. We reduced our bill by almost 40% :-)

Big thanks to my first readers and proofreaders: Ola, Magdalena and Paweł!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response