I have read pretty much the entire documentation even beyond on the AWS AS API to understand all the AS stuff.
However I am still wondering (without having actually used the API yet since I wanna find this out first from someone) if my scenario is viable with AS.
Say I got a bunch of work servers setup within an AS group all working on a job each and suddenly it comes the time (I dunno say, AVG CPU is greater than or in another case less than 80%) to scale up or down.
My main worry is the loss of a currently in progress job. Maybe this would be better explained with an example:
With this in mind is it better for me to just use the Amazon Spot Instance/EC2 API and just manage my own scaling or is there something I am missing about how the Amazon API judges server terminations?
To be honest I rather scale to SQS waiting amount than some health figure on the servers:
But this doesn't seem to be too viable with AS either.
So is the AWS AS API not the right solution or am I missing some vital info about how it works?
Thanks,
When demand drops, AWS Auto Scaling will automatically remove any excess resource capacity so you avoid overspending. AWS Auto Scaling is free to use, and allows you to optimize the costs of your AWS environment.
AWS Auto Scaling provides a simple, powerful user interface that lets you build scaling plans for Amazon EC2 instances and Spot Fleets, Amazon ECS tasks, Amazon DynamoDB tables, and Amazon Aurora Replicas.
Key differences in Amazon EC2 Auto Scaling vs. AWS Auto Scaling. Overall, AWS Auto Scaling is a simplified option to scale multiple Amazon cloud services based on utilization targets. Amazon EC2 Auto Scaling focuses strictly on EC2 instances to enable developers to configure more detailed scaling behaviors.
After some searching I found that there are two accepted ways to manage AS API or AS in general for jobs:
One method is to manipulate the health of a server directly from within the worker itself. This is what quite a few sites do and it is effective, when your worker detects no more jobs or redundancy in the system it marks the server it is on as unhealthy. This way the AS API comes along and automatically takes it down after a period of time.
So with this method you would have a scale up policy based on your SQS queue size over a period of time (say for every 5 mins of SQS messages being over 100 add 2 servers; every 10 mins of SQS messages being over 500 double network capacity by 50%). The scale down would be handled by code instead of an active policy.
This method would work with zero clusters too so you can down your cluster all the way to no servers when it's not being used making it quite cost effective.
Advantages:
Disadvantages:
With this in mind there is a second option, DIY. You use the EC2 Spot Instance and on Demand Instance API to make your own AS API based around your custom rules. This is pretty simple to explain:
Advantages:
Disadvantages:
So really it seems to be a battle of which is more comfortable for the end user. I personally am mulling the two still and have created a small self hosted server pooler that could work for me but at the same time I am tempted to try and get this to work on AWS' own API.
Hope this helps people,
EDIT: Note with either of these methods you will still require a function on your side to predict how you should bid, as such you will need to call the bid history API on your spot type (EC2 type) and compute how to bid.
Another Edit: Another way to automatically detect redundancy in a system is to check the empty responses metric for your SQS queue. This is the amount of times your workers have pinged the queue and received no response. This is quite effective if you use an exclusive lock in your app for the duration of the worker.
I just had the same kind of problem, and I talked to an Amazon guy who talked to me about the termination protection. In fact, if an instance has the termination protection activated, it can't be terminated. When a scale down is triggered, the app will be removed from the auto-scaling group, but it won't be terminated. To terminate it, you have to disable the termination protection and then terminate it (you can do that at the end of your job, for example).
To sum up, what you have to do is :
You can do all that using the AWS API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With