Amazon Auto Scale API for production servers

I read almost all of the documentation, even outside of the AWS AS API, to understand all the things AS does.

However, I'm still wondering (without actually using the API ever since I want to know this first from someone) if my script is viable with AS.

Let's say I have a set of working servers in the AS group, each of which is working on a task, and suddenly the time has come (I donโ€™t know that the AVG processor is more or less than 80% in another case) to increase or down.

My main concern is the loss of my current job. Perhaps this will be better explained with an example:

  • I run 5 production servers with 5 jobs on them
  • The task completes on one and launches a zoom out trigger in the Amazon API
  • Amazon comes to weaken them.
  • I am losing the job server on which the job is currently running (90% completed, you need to start again)

With that 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โ€™m missing about how the Amazon API evaluates server shutdown?

Honestly, I rather scale to the expected amount of SQS than some measure of health on servers:

  • for every 100 messages expecting a 20% increase in cluster capacity

But this does not seem too viable with AS.

So, is the AWS AS API not the right solution, or am I missing important information on how this works?

Thanks,

+6
source share
2 answers

After some searching, I found that there are two ways to manage the AS API or the AS as a whole for jobs:

One way is to manage the health of the server directly from the worker. This is what quite a few sites do, and it is effective when your employee does not find more jobs or redundancy in the system, he notes that the server is functioning as unhealthy. Thus, the AS API comes and automatically cleans it up after a while.

Thus, using this method, you will have a scaling policy based on your SQS queue size for a certain period of time (for example, every 5 minutes of SQS messages containing more than 100 additions of 2 servers, every 10 minutes of SQS messages will exceed 500 times the throughput network capacity by 50%). Zoom out will be done using code instead of the active policy.

This method will work with zero clusters, so that you can completely disconnect your cluster to servers if it is not used, which makes it quite cost-effective.

Benefits:

  • Easy setup
  • Using AWS API Features
  • Probably the fastest way to configure
  • Using AWS managed APIs to manage cluster size for you

Disadvantages:

  • It is difficult to manage without using the full AWS API, that is, when creating a new server, you will not be able to return it without running the full API command for all instances of the instances. There are other cases where the AWS AS API bothers you and makes life a little more difficult if you want a self-control element over your clan.
  • Based on Amazon, youโ€™ll find out whatโ€™s best for your wallet. You rely on the Amazon API to scale properly, this is an advantage for many, but for someone there is a drawback.
  • The worker must contain the code for your server pool, which means that the worker is not shared and cannot be immediately moved to another cluster without any configuration changes.

With this in mind, there is a second option - DIY. You use an instance of EC2 instance and the Demand Instance API to create your own AS API based on your custom rules. This is pretty easy to explain:

  • You have a cli script that, when launched, starts, say, 10 servers
  • You have a cronjob that, when it detects certain conditions, resets the servers or increases the volume

Benefits:

  • Simplicity and ease of use.
  • Can create generic workers.
  • Server pool can start managing multiple clusters
  • You can make rules and itโ€™s not difficult to get numbers from AWS metrics and use them with comparisons and time ranges to figure out if something is going to change.

Disadvantages:

  • Difficult to get multi-area (not so bad for SQS, since SQS is a single area)
  • It is difficult to cope with errors in the capacity and workload of the region.
  • You must rely on your own server uptime and your own code to ensure that cronjob works as it should and provides servers as needed and breaks them down when necessary.

So the battle seems to be more convenient for the end user. I personally think over two more and created a small self-contained server pool that could work for me, but at the same time I am tempted to try and get this to work on my own AWS API.

Hope this helps people

EDIT: Please note that using any of these methods you still need a function on your side to predict how you should bet, so you will need to call the bid history API on your place type (type EC2) and calculate how rate.

Other Editing. Another way to automatically detect redundancy in the system is to check the empty response metric for your SQS queue. This is the number of times your employees pinged a line and did not receive a response. This is quite effective if you use exclusive locks in your application during business hours.

+7
source

I had the same problem and talked to a guy from Amazon who was talking to me about termination protection. In fact, if an instance has activated termination protection, it cannot be completed. When scaling starts, the application will be removed from the auto-scaling group, but it will not be terminated. To complete it, you must disable completion protection and then complete it (for example, you can do this at the end of your work).

To summarize, you need to do the following:

  • Add a script to your AMI to activate completion protection.
  • Keep automatic scaling rules (scaling and scaling)
  • In executable instances, when it is safe to terminate an instance (end of job, ...), deactivate termination protection and terminate the instance

You can use all of this with the AWS API.

+1
source

Source: https://habr.com/ru/post/917388/


All Articles