Rackspace Cloud partner Kaavo knows that being able to autoscale your cloud applications is important. They also know that it can be a little tough to wrap your head around how to get this autoscaling working, so they’ve put together a fully-functional three-tier (load balancer, app server, database server) demo application to demonstrate it. This demo application is available to any Kaavo user, so it’s easy to go in and get your hands dirty.
Kaavo offers free 30-day demo accounts to its IMOD system. Just visit the Kaavo site and look for the “Sign-up for free trial” link.
Once you log into your IMOD account, you’ll see a list of available templates. These are packaged definitions that will set up environments for you. We’re going to to look at the “Linux php-colab 3tier-For-Rackspace” template. That will set up our three-tier architecture, and will install and run the phpCollab project collaboration application as well, so we’ll have a real-world product in place by the end.
Click on that option in the templates list, and you’ll see an XML file appear on the right. Kaavo uses XML to define these environments and control what they can do. A more user-friendly interface to handle common cases is in the works, but you can control nearly any aspect of the deployment from this XML file.
Each of the tiers is defined in a tier section in the XML. You can specify the order in which the tiers are displayed and the order in which they are started. Handy, of course, if your application needs its database online before the web servers attempt to talk to it. You can also specify command actions that will run as each server in that tier comes online. For example, in the above screenshot, you can see that in the web_tier (where the load balancer lives), there are several actions that run. We’ll take a look at how those actions are defined shortly, but the names should be pretty self-explanatory.
Scrolling down the XML, we can see the actual Cloud Servers that make up this tier. We can see that there should be a minimum of one and maximum of two load balancers running at any given point in the autoscaling cycle, and we should start up with 1. We’re using Cloud Server image 187811 (CentOS 5.4), and flavor 1 (256MB server). Those can be adjusted to taste. The other two tiers are set up in a similar manner, though in the db_tier you can see an example of having different server types within one tier.
Next in the XML, we see the actions defined. These are the scripts that will be run on the specified servers to perform the actions that we want. Some of the actions can be executable scripts, and some can just be raw files (config files and the like) that aren’t run. Below, we see both types in the screenshot below – one will install some RPMs, the other just sets up the MySQL cluster manager config file. Note that the execute attribute is set to “true” on the script, and “false” on the config file. Note also we’re specifying the path and filename.
There is also variable substitution available in these actions. In this action, we can see variables (parameters) set statically in the XML file, as well as ones dynamically generated (the IP addresses of the ndbd servers).
Finally, at the bottom of the file, there are event handlers, to run actions when states change, such as tiers are scaled up or down.
Ok, enough XML, let’s see how it works. At the top of the XML listing, fill in a system name and hit Deploy System. You’ll see that system listed under My Systems on the left. Click on that to see a diagram of your system and its tiers. You’ll notice that it’s “unconfigured” – you need to go into each system type and choose the Rackspace Cloud account to run them under, as well as adjusting images and flavors.
Once all systems are configured, you should see the initial configuration (number of servers, etc) as you defined in the XML. Now you can press the “Start System” button and wait. You’ll see spinners pop up in the display as servers are configured in the order that you specified. Enjoy the emails notifying you of the new servers that are being started. We’ll wait.
All done? Great! You should now have green lights and “Running” labels beneath all servers. If you click the blue triangle on your load balancer to get the Public IP, and open a web browser to that http://your-ip/phpCollab, you should see phpCollab! You can also go to http://your-ip/balancer-manager to see the Apache load balancer in action.
Now let’s throw some load at it. Click the “Event” button in IMOD, and choose the app-tier-overloaded event. This simulates what happens when load gets too high. You should immediately see another app server added to the mix. Visit the balancer-manager URL to see that the new server has been added to the mix.
If you’d like to play with the scaling parameters, configure the events through the IMOD UI. You’ll want to do this before starting the system, so that your changes are persisted.
Now, feel free to play around with the system, add traffic, modify the XML, enjoy! Remember, you have 30 days to run the system through its paces and figure out how Kaavo can help you leverage the power of the Rackspace Cloud.