문제

I was speaking with Rackspace tech support today looking for a simple solution to scale my server up / down based on load and he said that it could be done through their API programatically.

Has anyone actually done this before or have any advice on how to best approach this? I'd love to know if someone has some outline code or notes before I dive in and rewrite it from scratch.

Thanks! Walker

도움이 되었습니까?

해결책

Walker, what I would recommend to get you started is to prepare the servers in advance and then start and stop them using scripts fired off by a monitoring solution. Once you can consistently deploy quality approved servers in a automated way you would still need about 15 to 20 minutes to create a server. So either way you will need the resources to be ready when you need them.

Once you have your arsenal of servers at your beckoning, its time to prepare your monitoring solution. Nagios will work just fine for this task. Any monitoring solution that can respond to events with triggers etc will work.

There are a few ways to scale, understanding how to manage utilisation.

Utilization

This is unique to the project for us its a aggregated measure of System Load / Requests per second + IO. At the very least consider the load average. In our scenario we wanted to understand what made our systems busier and worked out our own utilization measures. Which we plugged into a custom monitoring solution. The utilization measures when we should scale up or out.

Scaling Up

Involves scaling to a larger server to serve requests, it literally means in order to server requests you have to migrate to larger servers. Or another way of thinking of it is the cost of a request would be reduced if it where served on a larger server.

In my experience the need to scale up is reduced in the short term. If you consistently require a minimum specification server to handle load then you should see average utilization levels grow. Once the utilization levels are around 60% consistently its time to start scaling up.

Scaling up can be costly so if you have peaks in load, you are probably better off just adding another server to the pool, thats how Scaling Out works.

Scaling Out

For most projects scaling out is more common in the short term, the process involves adding more hosts to a environment and distributing requests using a load balancer. When utilisation levels reach 60% or more a trigger in your monitoring solution fires a request that starts a host. When load returns to the median the monitoring solution switches servers off. It should be automatic and in switching servers off the utilization levels should increase. We try to maintain 40% utilization as a median for the environment.

The complexity is to automate the configuration of your load balancer to see the new hosts. I know of people that just preconfigure the balancer to use the health measure even after a server is switched off. The load balancer will not serve traffic to a dead host. When the servers start up the load balancer should see it again and begin to automatically serve requests to the server.

Final Solution

Deploy a minimum viable environment and set-up monitoring to watch for your own utilisation levels. Create triggers that start servers in your chosen environment. The triggers should execute a request that fires a call to Rackspace and starts a server. This is a good start.

Hope this has been helpful for you, and you go on to build a successful environment.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top