News for hackers. Stuff that matters.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by threeseed on Monday February 24, 2020 @10:33PM (#22410708)
I hope people don't go and take this advice and just run everything on Spot as that is a mistake.

It is very common for AWS to completely run out of entire classes of instance types e.g. all of R5 or all of M5. And when that happens your cluster will die.

What you want to do is split your cluster into minimum two node groups e.g. Core and Task:

Core: On-Demand for all of your critical and management apps e.g. monitoring. Task: Spot for your random, ephemeral jobs that aren't a big deal if it needs to be re-ran.

So for a Spark cluster for example you would pin your driver to the Core nodes and let the executors run on the Task nodes.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by someone13 on Monday February 24, 2020 @10:56PM (#22410794)
Shout-out for "AutoSpotting", which transparently re-launches a regular On-Demand ASG as spot instances, and will fall back to regular instances: https://github.com/AutoSpotting/AutoSpotting/

Combined with the fact that you can have an ASG with multiple instance types: https://aws.amazon.com/blogs/aws/new-ec2-auto-scaling-groups...

Means that you can be reasonably certain you'll never run out of capacity unless AWS runs out of every single instance type you have requested, terminates your Spot instances, and you can't launch any more On-Demand ones.

(and even so, set a minimum percentage of On-Demand in AutoSpotting to ensure you maintain at least some capacity)

Re:We use Kubernetes and spot instances to reduce EC2 billin... by londons_explore on Tuesday February 25, 2020 @03:10AM (#22411609)
> runs out of every single instance type you have requested, terminates your Spot instances, and you can't launch any more On-Demand ones.

This is more common than you think.

Internally cloud providers schedule instance types on real hardware, and running out of an instance type likely means they have run out of capacity, and only a tiny amount exists in fragmentation. To access that tiny remainder, they'll terminate spot instances and migrate live users (which they have to do very slowly) to make space for a few more of whichever instance types make most business sense (which varies depending on the mix of real hardware and existing instance types).

It takes someone like AWS a good few weeks, sometimes months, to provision new actual hardware.

It isn't uncommon for big users to be told they'll be given a service credit if they'll move away from a capacity constrained zone.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by cm2187 on Tuesday February 25, 2020 @03:46AM (#22411727)
Is there a similar concept to airline upgrading? Better than to deny a paying customer to board the plane. Surely there must be spare capacity, somewhere in the datacentre, with slightly better specs.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by londons_explore on Tuesday February 25, 2020 @03:55AM (#22411756)
Yes - they totally do that. If there is only space for a large instance, but you want a small one, they fit your small one in the free capacity, and there is now space for someone else to fit another small one next to it.

For business reasons they might decide not to do that though - your small instance might mean they have to say no to a big allocation later.

Instead they just delay your instance starting and hope other instances moving around opens up a more suitable location for it.

Theres an entire paper on the topic: https://dl.acm.org/doi/10.1145/2797211

Re:We use Kubernetes and spot instances to reduce EC2 billin... by alien_ on Tuesday February 25, 2020 @08:59AM (#22413204)
The AutoSpotting author here, always feels great to see my little pet project mentioned by happy users. Thank you for making my day!

To set matters straight, AutoSpotting pre-dates the new AutoScaling mixed instance types functionality by a couple of years and it (intentionally) doesn't make use of it under the hood for reliability reasons related to failover to on-demand. To avoid any race conditions, AutoSpotting currently ignores any groups configured with mixed instances policy.

In the default configuration AutoSpotting implements a lazy/best-effort on-demand->spot replacement logic with built-in failover to on demand and to different spot instance types. To keep costs down, it is only triggered when failing to launch new spot instances (for whatever reason, including insufficient spot capacity).

What we do is iterating in increasing order of the spot price until successfully launching a compatible spot instance (roughly at least as large as the original from CPU/Memory/disk perspective but cheaper per hour). If all compatible spot instances fail to launch, the group keeps running the existing on-demand capacity. We retry this every few minutes until we eventually succeed.

There's currently no failover to multiple on-demand instance types (this is a known limitation), but this could be implemented with reasonable effort.

We're also working in significantly improving the current replacement logic to address a bunch of edge cases with a significant architectural change(making use of instance launch events). I'm very excited about this improvement and looking forward to having this land, hopefully within a few weeks.

At the end of the day, unlike most tools in this space(including AWS offerings) AutoSpotting is an open source project so if anyone is interested in helping out implement any of these improvements(or maybe others), while at the same time getting experience with Go and using the AWS APIs, which are nowadays very valuable skills, you're more than welcome to join the fun.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by alien_ on Tuesday March 03, 2020 @04:19PM (#22478812)
Thanks for the shout-out, really appreciate it.

If you don't mind I'd like to get some feedback/feature ideas from users like you.

Please get in touch with me on https://gitter.im/cristim

Re:We use Kubernetes and spot instances to reduce EC2 billin... by ignoramous on Tuesday February 25, 2020 @12:49AM (#22411199)
ASG, per the blog-post you linked to, now supports starting both on-demand and spot instances, so what's the use of AutoSpotting?
Re:We use Kubernetes and spot instances to reduce EC2 billin... by alien_ on Tuesday February 25, 2020 @09:23AM (#22413411)
The author of AutoSpotting here, this is often being asked and I'm happy to clarify it.

The mixed capacity ASGs currently run at decreased capacity when failing to launch spot instances. AutoSpotting will automatically failover to on-demand capacity when spot capacity is lost and back to spot once it can launch it again.

Another useful feature is that it most often requires no configuration of older on-demand ASGs, because it can just take them over and replace their nodes with compatible spot instances.

This makes it very popular for people who run legacy infrastructure that can't be tampered with for whatever reasons, as well as for large-scale rollouts on hundreds of accounts. Someone recently deployed it on infrastructure still running on EC2 Classic started in 2008 or so that wasn't touched for years.

Another large company deployed it with the default opt-in configuration against hundreds of AWS accounts owned by as many teams, many with legacy instances running for years. It would normally take them years to coordinate as a mass migration but it just took them a couple of months to migrate to spot. The teams could opt-in and try it out on their application or opt-out known sensitive workloads. A few weeks later then they centrally switched the configuration to opt-out mode, converting most of their infrastructure to spot literally overnight and saving lots of money with very little configuration effort and very few disruption to the teams.

If you want to learn more about it have a look at our FAQ at https://autospotting.org/faq/index.html

It's also the most prominent open source tool in this space. Most competition consists of closed-source, commercial (and often quite expensive) tools so if you're currently having any issues or missing functionality, anyone skilled enough can submit a fix or improvement pull request.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by 616c on Tuesday February 25, 2020 @07:44PM (#22419197)
Where can I read about some of these more impressive use cases you describe?
Re:We use Kubernetes and spot instances to reduce EC2 billin... by alien_ on Wednesday February 26, 2020 @10:31AM (#22423833)
Have a look at https://github.com/AutoSpotting/AutoSpotting or the FAQ section on https://autospotting.org

If those don't answer your questions feel free to reach out to me and I'll do my best to explain further.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by kondro on Tuesday February 25, 2020 @12:58AM (#22411223)
It replaces on demand instances in-place. If there’s no spot instances, it will leave them running. If the spot instance gets killed, it will start again as on demand.

It sounds a bit hinky, but it tends to leave you with the number of instances you want running without having to determine what percentage of the ASG should be on demand or spot — especially with the possibility of not being able to start new spot instances if they’ve been terminated.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by samrohn on Monday February 24, 2020 @11:14PM (#22410855)
Yes. We ran into this early on. Setting your bid price(maximum price you are willing to pay for the resource you are spinning up) higher than the average spot price do not protect you against instance termination. Also even if you place your spot bid price at current on-demand price (you only get charged at the current spot market price) your instane will be terminated if there is no resource availble in the spot instance pool. For example, you have spin up an ec2 instance with 100 GB RAM with type spot instance, with bid price set to the on-demand price. If someone else spin up a 100GB as on-demand instance type- if there is no resource left in spot pool, your instance will be terminated.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by tuananh on Monday February 24, 2020 @11:29PM (#22410913)
author here: this is why i suggest to use mix of reserved instances and spot instances. worse case scenario, everything will be on the small number of reserved + on-demand instances.

there are other strategies to avoid this as well

using multiple type of instance, of different sizes, on different availability zones. because price spike is different for each combinations

using bigger size instance than usual because bigger = more stable / less likely to get evicted

Re:We use Kubernetes and spot instances to reduce EC2 billin... by ryeguy on Monday February 24, 2020 @10:42PM (#22410747)
Why not use spot fleets to solve this? You can specify multiple acceptable instance types.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by threeseed on Monday February 24, 2020 @11:20PM (#22410888)
I can't speak for the other regions but in ap-southeast-2 we had a couple of incidents in 2019 where there was no Spot capacity for ANY instance types between say 64GB and 512GB of RAM.

And so even our instance fleets were failing to provision capacity.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by ramraj07 on Tuesday February 25, 2020 @04:02AM (#22411781)
Requiring a minimum of 64GB RAM seems quite unique computationally, so if it's mission critical that you have at least one instance of this type all the time up, then maybe you could reserve that one instance fully while depending on spots for scaling?
Re:We use Kubernetes and spot instances to reduce EC2 billin... by tuananh on Tuesday February 25, 2020 @12:00AM (#22411027)
this is why ability to fall back to on-demand instances is critical.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by londons_explore on Tuesday February 25, 2020 @03:14AM (#22411617)
When there are no spot instances, it's common that on-demand instances can't be started either.

Unless you paid for a reservation, you're SOL.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by maniktan on Monday March 02, 2020 @05:29PM (#22469749)
Fwiw, Product@SpotInst here. Curious what makes you arrive at this conclusion? At SpotInst we have customers who migrate between Spot <--> RI <--> OD everyday.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by tuananh on Tuesday February 25, 2020 @03:29AM (#22411672)
that's for you to decide how many percent of reserved instances out of total compute power you need. it's always a trade off. in that case, pct of cost saving is lower but availability is higher.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by paulddraper on Tuesday February 25, 2020 @12:33AM (#22411147)
It seems weird that AWS wouldn't just do this automatically, right?
Re:We use Kubernetes and spot instances to reduce EC2 billin... by llarsson on Tuesday February 25, 2020 @12:48AM (#22411193)
Yes and no. Because they do not want to disclose how much capacity they have and on demand costs more, customers would be left wondering if AWS unfairly decided to run on demand when spot could have been used instead.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by halbritt on Monday February 24, 2020 @11:03PM (#22410819)
I'm also puzzled why people wouldn't just use spot fleet with on-demand as backup.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by tuananh on Monday February 24, 2020 @11:33PM (#22410930)
because at the time when we did this (2016-2017), kops did not support spot fleet. worst case scenario, you get mix of reserved + ondemand instances.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by CoolGuySteve on Monday February 24, 2020 @11:34PM (#22410936)
I don't think I've ever seen spotfleet not satisfy a request with all the same instance type. When the instance gets terminated, it seems to fill again with the same instance type as before (and then get killed again in busy periods).

For the past few weeks I've been having this exact problem with GPU instances, where on-demand requests would kill my spotfleet instances in the middle of a job, I'd spin up again, get killed again a few minutes later.

The only way to fix it without rewriting a bunch of stuff was to blacklist that instance type from my spotfleet requests.

It definitely wasted a bunch of my time though which seems to be increasingly more common with newer AWS APIs.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by maniktan on Monday March 02, 2020 @05:46PM (#22469908)
Fwiw, Product@SpotInst here. Might I suggest that you give us a try. We ward off against this specific scenario by calculating a Spot score based on Instance Type/AZ and deliver flexibility with a choice of different instance types.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by tuananh on Monday February 24, 2020 @11:32PM (#22410929)
because at the time when we did this (2016-2017), kops did not support spot fleet
Re:We use Kubernetes and spot instances to reduce EC2 billin... by maniktan on Monday March 02, 2020 @05:19PM (#22469664)
Fwiw, I lead Product for Ocean at SpotInst. Your analysis is _spot_ on :). At SpotInst, we predict interruptions by calculating a Spot Market Score which is based on Instance Family, Type and AZ (using historic data). This allows us to spread pods/workloads across a variety of spot instance types while delivering an SLA. As an additional data point, we have a mix of stateless/stateful workloads running 24x7 on our platform. For critical/management workloads/apps, RI could make a lot of sense and we can dynamically buy/sell those on your behalf, delivering a fully-managed Spot <--> RI <--> OD solution where needed.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by croddin on Tuesday February 25, 2020 @03:08AM (#22411600)
Fargate spot is out now and pretty nice, since it is just running a container of a certain size and can decide where it is run it seems like it would be less likely to run out of capacity as well.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by rumanator on Tuesday February 25, 2020 @06:11AM (#22412289)
The main problem with AWS Fargate, as with most of AWS's offering, is cost. More precisely, granularity. AWS Fargate cost infrastructure, at best, charges you per ceiling of 0.25 vCPU and 0.5GB of RAM (rounded up) per second, with a ceiling of 2GB of RAM. If your containers have some spiky workloads that require more than 2GB of RAM then the coarseness goes up and your are charged per 1GB of RAM (rounded up) per second. That means a spiky workload can lead you to spend more than a month's worth of a EC2 instance with 2GB of RAM (say, T3.small with 2vCPU and 2GB of RAM).

The whole service becomes even more ridiculous if a company is already operating EC2 instances or even kubernetes clusters on EC2 spot instances (the topic of this discussion), because more often than not these workloads can be already covered by the cluster's unused capacity.

Re:We use Kubernetes and spot instances to reduce EC2 billin... by maniktan on Monday March 02, 2020 @05:57PM (#22469991)
Product@SpotInst here. Just fyi, we have customers launch Spark workloads that require 300G RAM and we are able to efficiently deliver this capacity by ensuring that the underlying infrastructure is shared with other pods that are not memory bound. We bin-pack, scale up and down quickly, while allowing you to have warmed-up spare capacity when needed to ensure that your pods/tasks are serviceable immediately.
Re:We use Kubernetes and spot instances to reduce EC2 billin... by teddyuk on Tuesday February 25, 2020 @04:06AM (#22411795)
I spent months in the summer of 2018 not able to deploy azure gs4/5’s in north or west Europe - such a pain
Re:We use Kubernetes and spot instances to reduce EC2 billin... by hinkley on Tuesday February 25, 2020 @10:36AM (#22413954)
are you using or have you built and dashboards to track this sort of stuff? It seems like deprioritizing certain types of work to save money might warrant some sort of forecasting info. Should I rely on something happening today or not?