To perform a standard health check test to make ensure proper communication between HAProxy load balancers and the application servers in its load balancing pool.
Table of Contents
In this tutorial, you will perform the following actions:
The first step is to check your load balancing pool to make sure that you have at least two operational application servers. There are two different ways to check the load balancing pool to make sure that all running application servers are properly connected to a load balancer.
The following test shows a mapping of the Resource ID of the array servers with their internal, Private IP Address. In the example below, the traffic to these servers is routed over port 8000.
cd /home/haproxy/ less rightscale_lb.cfg
server i-f3ee8795 10.203.85.169:8000 check inter 3000 rise 2 fall 3 maxconn 255 server i-a3d1b8c5 10.204.97.84:8000 check inter 3000 rise 2 fall 3 maxconn 255
Add "/haproxy-status" to the end of the URL to see which application servers are part of the HAProxy load balancing pool. (e.g. www.example.com/haproxy-status)
You should see the instance ID of each operational application server. If an application server is properly connected to the HAProxy servers in the load balancing tier, it will be listed in a row highlighted in green. If the server is highlighted in red, the application server is not in the load balancing pool and will not receive any requests from a load balancer server.
The next step is to create a simple RightScript that tests the ability of the load balancers to send incoming requests to the application servers in a rotating fashion.
#!/bin/bash -ex cat > /home/webapps/$APPLICATION_NAME/servername.html << EOF <html><body><center><h1>Which application server am I connected to?</h1> <h2>Instance ID: <font color="blue"> EOF cat /var/spool/cloud/meta-data/instance-id >> /home/webapps/$APPLICATION_NAME/servername.html cat >> /home/webapps/$APPLICATION_NAME/servername.html << EOF </font></h2></center></body></html> EOF
A common misconception is that you can't use RightScripts in a ServerTemplate that primarily uses Chef cookbooks and recipes. In fact, you may find it easier to create simple RightScripts to perform simple actions instead of creating a Chef recipe that accomplishes the same task.
Since a server's scripts are defined by its ServerTemplate and you launched the application server(s) with an editable HEAD version of the application ServerTemplate, you can now test the script on a running server.
If the previous test was successful and you want to save the changes, commit the ServerTemplate. Since the ServerTemplate has a HEAD RightScript, you will be prompted to also commit the RightScript as part of the same action. Make sure the checkbox is checked. When you commit a HEAD ServerTemplate that references a HEAD RightScript, both components will be committed and new, static revisions will be created. The new ServerTemplate revision will reference the latest revision of the RightScript. However, the HEAD ServerTemplate will continue to reference the HEAD RightScript so that you can continue to make modifications to the script, which is useful during development cycles. However, if you do not want to make any further changes to the script, you can select the most recently committed revision of the RightScript under the HEAD ServerTemplate's Scripts tab.
© 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.