This guide shows the logical steps how we implemented auto-scaling functionalities in a private cloud at 52°North Initiative for Geospatial Open Source Software GmbH.
Auto-Scaling in principle:
The CPU utilization of running instances is requested in defined intervals. If a specific threshold is reached, a new instance will be started recpectively stopped.
This is done by running a web service on each instance that responses the instance's CPU utilzation as well as a program that calculates the average of all CPU utilizations and starts/terminates instances.
Since we are using sysstat for getting the instances' CPU utilization, using Linux as the images' OS (in our case Ubuntu 9.10) is requires .
Following the steps to implement auto-scaling functionalities in a private cloud:
1. Configuring the image:
sudo apt-get install sysstatIf this web service is requested, the instance's CPU utilization is retrieved by the console command sar 1 1 After parsing the command's output, the web service responds the CPU utilization.
This web service is deployed as a webapp in the servlet container as described above.
2. Implementing auto-scaling functionalities:
To implement the auto-scaling functionalities another program needs to be written.
This program runs on the CC and requests the IP adresses of the running instances by the command euca-describe-instances For these instances the web services, which gives you the CPU utilization (see poin 1), are requested (e.g. for every running instance: "http://instance-ip/cpuLoad"). If this average of all instance's CPU utilizations exceeds respectively goes below a specific threshold, a new instance will be started (euca-run-instances) recpectively stopped (euca-terminate-instances). This is repeated in a defined interval (e.g. every 30 seconds).
That's it!
More details
Hi,
I really like your solution but I'm not an expert in web server and I would like to reproduce your test. May you provide more details (end even source code of the script) of your work?
Thanks,
Massimo
Thanks to you and wiki's
Thanks to you and wiki's explanations about the amazon elastic compute cloud I finally got to understand more. Linux is my favorite operating system, and I really wanted to be able to configure images by myself. I wanted to ask you, is there a good registry cleaner for Linux too? Thanks
vertical scaling
what for you don't add resourcein current machine.isn't this better than terminating and running a new one?
Load balanced?
Are you instances load balanced?
If so, were you using a software load balancer like HAProxy or something? Like when you hit the threshold, add the new instance under some load balancer with some http health checking.
Arwin
An alternative not requiring an additional package
As a possible alternative to getting system load through a cmd line call, write a small webservice, perhaps jax-rs, that does the following
java.lang.management.OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
double load = bean.getSystemLoadAverage();
return load;
This returns the avg system load for the last minute. This would require the java rt to be java 6.
A question about the CPU utilization of running instances
Hi wcorey:
I hava a question about the CPU utilization of running instances。I tried your suggestion to show the CPU utilization of running instances,but found that it was not the same to the CPU utilization which showing on NC(Node Controller)。I don’t know how you got the CPU utilization of running instances。Can you help me?
Thanks in advance!
I cann't decide to terminate the instance which is running.
Thanks for your help! According to your advice, I am trying to construct the autoscaling function on the Eucalyptus.
But I happened a problem with that the average of all instance's CPU utilizations belows a specific threshold,I cann't
decide to terminate the instance which is running. Can you help me?
Thanks in advance!
We also safe the cpu
We also safe the cpu utilization for each instance separately. So, if we want to terminate an instance, we are looking for the one with the minimum cpu utilization and terminate that one.
Since it is not guaranteed that this machine is not working on a request (we are deploying a webservice) at the moment, it is not the most sophisticated solution. It is possible, that a request gets lost.
But for our purposes this solution works.