Autoscaling Setup

Overview

Once you've set up up your production deployment, you're probably already thinking about "How do I set up my deployment to autoscale?" 
 

In order to create a scalable deployment, you need to define an alert and escalation, and then specify the appropriate server template and array that you want to scale.  An alert is a notification that a problematic condition occurred in your deployment. An escalation performs an action when a particular alert is triggered.  Together, they can be used to configure your deployment to automatically take action on your behalf.
 

For example, if your site is experiencing a large amount of traffic, you can set up an alert and escalation to grow or "scale" your deployment, where more server resources are added to your server array in order to handle the increased bandwidth requirements.  Therefore, you can set up your deployment to automatically scale based on particular alerts and escalations that you define.

Objective

To set up a deployment so that it will automatically scale based on an alert and escalation that you define.  In this example, we will configure the deployment to "grow" or add more application servers to satisfy an increase in bandwidth requirements.

NOTE: This tutorial only applies to Premium accounts.  If you have a Developer account, you will need to contact sales@rightscale.com to upgrade.  

This tutorial shows you how to change a basic 4-instance setup into a scalable deployment with a scalable application server array.

Basic 4-Instance Setup

The basic setup has two FrontEnds (load balancer + app server), as well as a Master and Slave database. 

alerts_escalations_diag1.gif

 

Scalable Setup with a Scalable Application Server Array

When additional server resources are needed in a scalable setup, new servers are launched and added to the server array.  When those resources are no longer needed, the application servers can be terminated and removed from the server array while the basic 4-instance setup stays intact.  Autoscaling is especially useful for ensuring that your deployment can easily scale up whenever extra server resources are needed, whether that's tomorrow, next week, next year, or perhaps never.  At least you know your deployment is set up to take advantage of one of the key benefits of cloud computing--launching additional server resources on demand.

alerts_escalations_diag2 (1).gif

 

This tutorial is divided into 5 Steps:

Step 1: Create a Server Array
Step 2: Create Escalations
Step 3: Create Alerts
Step 4: Attach Alerts and Escalations to the FrontEnds
Step 5: Attach Alerts and Escalations to the Server Template for Arrays

 

Step 1: Create a Server Array

Go to Manage -> Arrays and click on New to create a new array. 

alerts_escalations_11.gif

Define the Array

The next step is to configure the array and define how the array will be scaled.

02-server_arrays_new_alert.gif

  • Provide a Nickname for the server array.
  • Array type: Alert-based
    There are two types of server arrays: Alert-based or Queue-based. 
  • Choose the server template that you would like to use in order to scale your deployment.  This template will be used to create the new servers that will be added to the server array.   Since you are scaling the number of application servers, you will need to select the latest version of the appropriate (PHP/Rails/TomCat) application server template, not a frontend server template.
    NOTE:
    Make sure that the inputs for the template are properly configured and that they will boot correctly.
  • Specify the appropriate SSH key, Security Group, and Deployment that will be attached to this array.  Currently, you can only have one array per deployment. If you need to scale multiple servers, you will need to create multiple deployments.
  • Default min count: 2
    The min_count is the minimum number of servers that you want running at any given time.  If you have a basic 4-instance setup with two frontends, then set this value to 2.
  • Default max count: 20
    The max_count is the maximum number of servers that you can run at any given time.  Premium users can launch up to 20 servers.  If you need to launch more than 20 servers, you will need to contact the RightScale Sales team about the new pricing structure.
  • Decision threshold: 51%
    The elasticity decision threshold is the percentage of servers that must agree in order to trigger an alert before an action is taken. We recommend setting this value to 51% in order to ensure that the majority of your servers agree before action is taken. Our voting system ensures that you don't launch a bunch of new servers because one of your servers went "out of control."  This is what we mean when we say that we scale democratically.
  • Resize by: 2
    The resize parameter defines how many servers you want to launch when you scale.  When a decision is made to "grow an array," we recommend launching at least 2 servers in order to ensure that a significant impact will be made to your setup.  If your deployment needs more server resources, it's better to over compensate than under compensate.  Similarly, if you have larger setups or you have a predictable scaling pattern (ex: 5 servers at a time), you also have the flexibility to scale in bulk.
  • Resize calm time: 15 (minutes)
    The calm time defines how long you want to wait before you repeat another action.  Since it takes a few minutes for a new server to be launched and become fully operational, you'll want to give yourself a buffer before taking another action.  For normal situations, we recommend using a calm time of 15 minutes.

Click Save.

 

Enable the array

Be sure to enable (activate) the array that you just created. Even if you attach an array to a server template, nothing will happen unless you enable the array.

alerts_escalations_16.gif

Click Enable

 

Step 2: Create Escalations

The next step is to define the action(s) to be taken when an alert is triggered.  An escalation can have one or more actions.  We will create two escalations:

  • "vote_grow_array" - scale up deployment by adding new server resources to app server array.
  • "vote_shrink_array" - scale down deployment by terminating (removing) server resources of the app server array.

arrays_scaling_esc_v2.gif

vote_grow_array

To create a new escalation, go to Design -> Alerts -> Escalations and click the New button.

alerts_escalations_2.gif

Enter a name and a description for the new alert escalation.  You will also need to associate the escalation to a deployment.  If you have followed the other tutorials, attach this escalation to your "Production" deployment and click Save.

NOTE: You will need to remember the name of the new escalation ("scale-up") when you create an alert in the next step.

alerts_escalations_3.gif

Now that you've created a new escalation you'll need to define what action should be taken when the alert is triggered.   In this example, we want to add server resources to the application array. i.e. "grow the array."

Click on the Actions tab.

You'll notice that we've pre-defined several common actions that can be associated with escalations. 

Select the “vote_grow_array” action from the pulldown bar and click Add.

alerts_escalations_4.gif

Since we want the server array to grow immediately, leave the "Escalate after" (escalate to the next action after n minutes) field blank or type zero and click Save.  

alerts_escalations_5.gif

vote_shrink_array

Now that we've created an escalation to grow the server array, we need to create another escalation to shrink the server array. 

Click the New button to create another escalation.

alerts_escalations_18.gif

Enter a name and a description for the new alert escalation.  Associate the escalation to the same deployment as the scale-up escalation.  Click Save.

alerts_escalations_17.gif

Now define the action for the scale-down escalation.

Click on the Actions tab.

alerts_escalations_20.gif

This time select the “vote_shrink_array” action from the pulldown bar and click Add.

Now that we've set up escalations to grow and shrink the array, let's configure the alerts.

 

Step 3: Create Alerts

Next we need to define the alert specifications.  Go to Design -> Alerts -> Specifications.   We will create two alerts:

  • "Need to Grow Array" - an alert indicating that it is now time to scale up the deployment and call the "scale-up" escalation.
  • "Need to Shrink Array" - an alert indicating that it is now time to scale down the deployment and call the "scale-up" escalation.

arrays_scaling_alert_esc_v1.gif


To create an alert specification, go to Design -> Alerts -> Specifications, and click the New button.

alerts_escalations_9.gif

Need to Grow Array

First give it a name and description.  Let's configure this alert to trigger when the CPU Idle value is less than 30% for 3 minutes.  If a server is at over 70% capacity, it may be a good time to scale-up and launch a couple more servers.

alerts_escalations_21.gif

  • Select cpu-0/cpu-idle as the file (metric) that you are monitoring.  This is the cpu-idle value of the server.
  • Select value for the variable.
  • Select less than < as the condition.
  • Type 30 for the threshold since we want to trigger this alert when the computer's idle time is less than 30%.
  • Type 3 for the Duration, since we want the condition to exist for 3 minutes before triggering an escalation.
  • Type the name of the escalation that you want to call when the alert this alert is triggered.
    NOTE: You will need to use the same name that you used to create the escalation in the previous Create Escalations step. Ex: scale-up

Click Save.

Need to Shrink Array

Next, we need to create the converse alert specification that will indicate when it is time to shrink the array and scale-down the deployment.

Click New.alerts_escalations_22.gif

 

Give it a name and description.

Except this time, let's configure this alert to trigger when the CPU Idle value is more than 85% for 3 minutes.  If a server is only using 15% of its CPU power, this may be a good indicator that it's time to scale-down and terminate some unnecessary server resources.

 

 

 

 

 

 

 

 

 

 

 

Step 4: Connect Alerts and Escalations to the FrontEnds

Now that you've created the necessary alerts and escalations in order to scale-up and scale-down, the next step is to connect them to your deployment.  First, we will connect them to the two FrontEnds.

arrays_scaling_frontend_v1.gif

Go to the Production deployment and select each of the FrontEnd templates.  Select FrontEnd-1.

alerts_escalations_23.gif

 Click on the Alerts tab.

alerts_escalations_24.gif

Select the Need to Grow Array alert and click Attach

Select the Need to Shrink Array alert and click Attach.

Both alerts are now attached to FrontEnd-1.  Repeat these steps and add the same alerts to FrontEnd-2.

 

Step 5: Connect Alerts and Escalations to the Array Server Template

The last step is to connect the alerts to the server template that will be used to launch new servers into the application server array.   This will ensure that any server that gets added to the server array will also have the same alerts as the two FrontEnds.

NOTE:  If servers have alerts, they must also have "SYS Monitoring install" installed.   See Alert System.

arrays_scaling_appserver_v1.gif

Go to Manage -> Arrays. 

Select the appropriate server template for the scalable array.  ex: PHP App Server v3 (clone)

NOTE: If you choose a server template from the Premium list you will not be able to add an alert to it until you clone it.

alerts_escalations_26.gif


Select the Alerts tab.

alerts_escalations_27.gif

To attach an alert to the server template, select it from the list and click Attach.  

Select the Need to Grow Array alert and click Attach

Select the Need to Shrink Array alert and click Attach.

Both alerts are now attached to server template that will be used to launch new servers.  Therefore, whenever a new server is launched and added to the application server array, it will have the same alerts as the FrontEnds.

Congratulations!  You just set up a scalable deployment that is configured to grow and shrink its server array when the CPU Idle value triggers an alert and escalation.   You can also set up an escalation that will also send an email whenever a particular action is taken in your deployment.  But, be careful. You don't want to become a spammer!

 

 ----------------------

Did you find this document helpful?  Please feel free to leave us a comment below so that we'll know how we can improve our documentation.  Thanks!

Tag page
Viewing 1 of 1 comments: view all
this is pretty good but the alert section is out of date.
Posted 15:50, 27 Jul 2008
Viewing 1 of 1 comments: view all
You must login to post a comment.