To create dedicated load balancer servers that will use HAProxy to send incoming client requests to one of the registered application servers in the load balancing pool.
Table of Contents
In order to create a high-availability load-balanced web server solution in the cloud, RightScale has published load balancer ServerTemplates that run HAProxy. This is a software load balancer with high reliability that automatically checks the health of your application and decides whether to forward traffic to a particular server based on these health checks. To provide extra functionality, we also run Apache in front of HAProxy, which allows you to serve static pages locally and establish SSL connections with only a slight increase in latency. To the right is a conceptual overview of the flow of user traffic.
As you can see, user traffic comes in through Apache on port 80. Apache then decides which pages to serve directly and which pages to forward to HAProxy (on port 85 by default). Since HAProxy has a list of application servers and is constantly performing health checks, it knows which servers are available to handle requests. It then proxies these requests to an appropriate server. Once an application server receives the request, it generally communicates with the backend database.
This tutorial will show you how to set up the minimum deployment requirements for a "high availability" site. The setup consists of a redundant Master/Slave MySQL setup, a pair of dedicated load balancer servers, and two application servers. See the diagram below for details.
Go to Manage > Deployments. Click on your "production" Deployment.
Next, we will add two load balancer servers using the same ServerTemplate. Go to Design > MultiCloud Marketplace > ServerTemplates. Import the latest "RightScale Load Balancer with Apache/HAProxy" ServerTemplate (RightScale is the publisher) so that a copy is saved in your RightScale account's 'Local' collection. (Design > ServerTemplates)
Since these ServerTemplates are fairly straightforward in their configuration and typically do not need to be customized, you can use the ServerTemplate as-is to add servers to the Deployment. When viewing the ServerTemplate, click the Add to Deployment button.
Select into which cloud/region you want to launch the Server.
Next, select your "production" Deployment. Since you're going to launch two load balancers in different availability zones for high-availability purposes, name the first load balancer something like my-lb1, select the same availability zone as your Master-DB, and select the first Elastic IP that you reserved earlier in the Create Elastic IPs (EIP) tutorial. You can also select the same SSH Key and Security Group that you created in earlier steps.
For more information on adding a server, see the Add Server Assistant.
Although you could repeat this process to add the second load balancer server, an easier way would be to simply clone the first load balancer. Click the nickname link of the first load balancer (e.g. my-lb1) and click the Clone button.
Change the following information on your cloned Server:
You should now have two dedicated Load Balancer Servers and two MySQL Database Servers in your Production Deployment. Notice that both tiers are equally dispersed across multiple zones.
Now you need to define the Input parameters for your Deployment. Click on the deployment's Inputs tab. As a best practice, we recommend defining Input parameters at the Deployment level.
By defining Inputs at the Deployment level, you can view and define all Input parameters that need to be set for all Servers in your Deployment in one place. Use the following guidelines to help you properly configure inputs.
Notice that most inputs already have default values that were set at the ServerTemplate level. Inputs will be inherited from a ServerTemplate unless they are defined at the Deployment or Server level.
When you are ready to set your Input values, click Edit. Once you have configured all of the Inputs click Save.
Once again, most of the generic inputs have been defined for you at the ServerTemplate level. However, there are a few new inputs that are user-specific and need to be defined at the Deployment level. Use the input's hover text to view its description and determine what value should be set.
|Name||Input Type ||Description|
Sets the directory for your application's web files. (/home/webapps/APPLICATION/current/)
The URI of the health check page, used by HAProxy for checking whether the site is up or not. You must create your own health check page, which returns an HTTP status of OK 200. The contents of the page are not important, but its name should be unique (preferably containing a random number). The same page is used for all application servers to determine whether the server is running (up). For example, if the page were http://www.mydomain.com:80/hlthchk378923.html, you would simply specify a HEALTH_CHECK_URI of: /hlthchk378923.html. (Note: Be sure to include the slash before the file name.) The page content could simply be the text: "OK."
If you do not have a health check page, select "ignore."
The fully qualified hostname of all the servers that have HAProxy installed on them for load balancing purposes. For example, if www.domain.com has two dedicated load balancers with HAProxy installed on them, you would enter www.domain.com as the LB_HOSTNAME. It is necessary that these hosts be registered with DNS with matching A Records so that the application servers will be able to connect to and disconnect from all the HAProxy servers and update their configuration files.
The fully qualified domain name that the server will accept traffic for.
Warning: If you want HAProxy to perform health checks on your web site, remember to include the health-check file in your application bundle. If you do not do this, you will receive errors similar to the following in your log file:
"GET /health_check.jsp HTTP/1.0" 404 1003 "-" "-"
For more information on this, please see the Health Check Page.
Now that you've defined all of the required Input parameters, you are now ready to launch the Load Balancer Servers. Since you defined all of the required inputs at the Deployment level, you can launch both of them at the same time.
Go to the Deployment's Servers tab. Check the Load Balancers and use the Launch action.
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.