<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Official Rackspace Blog &#187; Brandon Woodward</title>
	<atom:link href="http://www.rackspace.com/blog/author/bwoodward/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rackspace.com/blog</link>
	<description>The Official Rackspace Blog</description>
	<lastBuildDate>Tue, 21 May 2013 15:00:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Installing and Configuring LVS-TUN</title>
		<link>http://www.rackspace.com/blog/installing-and-configuring-lvs-tun/</link>
		<comments>http://www.rackspace.com/blog/installing-and-configuring-lvs-tun/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 14:27:15 +0000</pubDate>
		<dc:creator>Brandon Woodward</dc:creator>
				<category><![CDATA[Product Announcements and Updates]]></category>
		<category><![CDATA[Tips for Devs and Sys Admins]]></category>

		<guid isPermaLink="false">http://www.rackspacecloud.com/blog/?p=6528</guid>
		<description><![CDATA[EDITOR&#8217;S NOTE: Due to a global shortage of IPv4 addresses, we are no longer allowed to give out additional IPs unless they are for SSL certs. This is a Rackspace policy and we can not add an IP for any other reason. The throughput of an individual server can be the bottleneck for almost any [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright" style="border: 0pt none; margin: 3px;" title="LVS-TUn" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/lvs4p-200.gif" alt="" width="200" height="200" /></p>
<p><span style="color: #ff0000;"><strong>EDITOR&#8217;S NOTE: Due to a global shortage of IPv4 addresses, we are no longer allowed to give out additional IPs unless they are for SSL certs. This is a Rackspace policy and we can not add an IP for any other reason.</strong></span></p>
<p>The throughput of an individual server can be the bottleneck for almost any Cloud based server.  With restrictions placed on a shared environment, you may find that you can no longer grow your solution horizontally behind a proxy load balancer.  There are options to work around this, the first and easiest being DNS round robin load balancing. DNS round robin load balancing isn’t smart and will just keep rotating, even if a node goes down – this is a huge downside.</p>
<p>You’ve got other solutions though; I want to introduce you to LVS-TUN, a tunneling load balancer.  The Linux Virtual Server project has been around for a while now, and has had different iterations, but LVS-TUN seems to work best on our infrastructure.</p>
<p><a href="http://www.linuxvirtualserver.org/">http://www.linuxvirtualserver.org/</a></p>
<p>LVS-TUN is a tunneling load balancer solution that will take all incoming requests through the load balancer and forward the packet to the web nodes. The web nodes will then respond directly to the client without having to proxy through the Load Balancer. This type of solution can allow for geo-load balancing, but will more importantly allow a customer use the bandwidth pool available from all web nodes, instead of relying on the limited through put of the load balancer.</p>
<p><strong>PREREQUISITES</strong></p>
<ul>
<li>2 x 256MB Cloud servers to serve as Load Balancers, running Centos 5.5</li>
<li>2 x 256MB Cloud servers to serve as Web Nodes, running Centos 5.5</li>
<li>An additional IP on Load Balancer 1, shared with Load Balancer 2 and all Web nodes.</li>
<li>All servers must be on the same Huddle.</li>
<li>All servers must share an IP (explained later in this article)</li>
</ul>
<p><strong>INSTALLATION</strong></p>
<p><strong>Networking:</strong></p>
<p>A shared IP address must be common among all Load Balancers and Web nodes in this cluster.  Also another thing to remember is that all of your servers will need to be on the same Huddle in cloud servers; the IP pools available in Cloud Servers are restricted by Huddle.</p>
<p><strong>Load Balancers (aka Directors):</strong></p>
<p>What to install on your Load Balancers:</p>
<ul>
<li>piranha</li>
</ul>
<p># This list is pretty short, but installing this package through YUM will install all necessary dependencies to get you working.</p>
<p># Make sure to make it start on boot with “chkconfig pulse on”.</p>
<p>The LVS-TUN Load Balancer’s configuration will be identical on both servers.  First we need to make a couple of changes to the sysctl.conf file; these kernel parameters will allow for things like the shared IP to be bounced between Load Balancing Nodes.</p>
<p>sysctl.conf:</p>
<pre>net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.ip_nonlocal_bind = 1</pre>
<p>Once you’ve made changes to this file, run ‘sysctl –p’ to make them live inside your system.</p>
<p>Moving on to the LVS-TUN service configuration file, which is found at /etc/sysconfig/ha/lvs.cf; this will configure both the load balancing and fail over service.   The service that will read this file is <a href="http://linux.die.net/man/8/pulse">pulse</a>, and is installed as part of piranha.  Pulse is a heartbeating daemon for monitoring the health of the nodes on your cluster.</p>
<ul>
<li>Remember to increment the serial number each time that you make a change to this file, or you won’t see the change go into effect.</li>
<li>If you want to run HTTPS, don’t run a health check on port 443; the system doesn’t fully support health checks over HTTPS that I could find.</li>
</ul>
<p>You’ll want to ifdown the shared IP, usually eth0:1, and then delete its configuration file in /etc/sysconfig/network-scripts/.  The pulse service will bring the IP live on the currently active load balancer, instead of the networking service used in most RPM based systems.</p>
<p>/etc/sysconfig/ha/lvs.cf</p>
<pre># serial must be incremented every time that a change
#is made to this configuration file
serial no = 1
#primary IP for your master LB, used as an identification
primary = 184.106.233.251
primary_private = 10.179.109.69
#primary IP for your slace LB, used as an indentification
backup = 184.106.233.252
backup_private = 10.179.119.61
# must be listed as active, or slave will terminate pulse
backup_active = 1
# Failover Options
heartbeat = 1
keepalive = 2
deadtime = 15
# LVS Type
service = lvs
network = tunnel
debug_level = NONE

##  Simple HTTP configuration
virtual http-pool {
active = 1
# the VIP that you want to bind to, this
# is only a forward and will not show up in a netstat
address = 172.x.x.x eth0:1
vip_nmask = 255.255.255.255
port = 80
persistent = 600
pmask = 255.255.255.0
send = "GET / HTTP/1.0\r\n\r\n"
use_regex = 0
load_monitor = none
scheduler = wrr
protocol = tcp
timeout = 6
reentry = 15
quiesce_server = 0
server web01 {
address = 10.x.x.1
active = 1
weight = 10
}
server web02 {
address = 10.x.x.2
active = 0
weight = 10
}
}

## SSL Configuration
virtual ssl-pool {
active = 1
address = 172.x.x.x eth0:1
vip_nmask = 255.255.255.255
port = 443
persistent = 600
pmask = 255.255.255.0
load_monitor = none
scheduler = wrr
protocol = tcp
timeout = 6
reentry = 15
quiesce_server = 0
server web01 {
address = 10.x.x.1
active = 1
weight = 10
}
server web02 {
address = 10.x.x.2
active = 0
weight = 10
}
}</pre>
<p><strong>Web Nodes configuration (aka Real Servers):</strong></p>
<p>Install your Web Head as you normally would &#8211; apache, lighttpd or nginx.  It shouldn’t make a difference which http service you are running.  The main changes that we will be worried about will be to the sysctl parameters and a Tunneled IP address.  Just like the Load Balancers, let’s start by running ifdown on the VIP, eth0:1, and then deleting its configuration file.  We’ll reconfigure the IP as a tunnel on the web nodes a little later.  First let’s make a few changes to sysctl.conf; we’re doing a few things in this file.  These changes need to be made due to the default settings that come from Centos, which would normally block this type of transaction.</p>
<p>sysctl.conf:</p>
<pre>net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.tunl0.arp_ignore = 1
net.ipv4.conf.tunl0.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 1024 65536
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
net.ipv4.conf.tunl0.rp_filter = 0</pre>
<p><strong>Tunnel device:</strong></p>
<p>Ok, here is a very important step: this tunneled IP will allow the web-node to respond directly to client giving the Virtual IP address shared amongst the cluster.  This shared IP makes the client think that it is still talking to the load balancer, so the connection is never terminated.</p>
<p>/etc/sysconfig/network-scripts/tunl0:</p>
<pre>DEVICE=tunl0
TYPE=ipip
# this is the shared IP from the Load Balancer
IPADDR=172.x.x.x
NETMASK=255.255.255.255
ONBOOT=yes</pre>
<p>Once you’ve saved this file, you can bring up the tunnel with ‘ifup tunl0’.  It should show up in ifconfig like any other IP and it should be listed as an ‘ipip’ type.</p>
<p>START LOAD BALANCING:</p>
<pre>starting:
/etc/init.d/pulse start

reloading:

/etc/init.d/pulse reload

stopping:
/etc/init.d/pulse stop</pre>
<p>Once your load balancer is up and running, you’ll want to run ‘ipvsadm’; this will tell you which load balancer is currently active and which web-nodes are active behind that load balancer.  The active balancer will give a similar answer:</p>
<pre>[root@lvs01 ~]# ipvsadm

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

-&gt; RemoteAddress:Port                 Forward             Weight             ActiveConn             InActConn

TCP  174-x-x-x.static.cloud- wrr

-&gt; 10.x.x.x:http                       Tunnel              10                             0                      0

-&gt; 10.x.x.x:http                       Tunnel              10                             0                      0</pre>
<p>Once everything is up and running, your load balancer should take a request and forward the packet to your web-node.  Then, the web-node will respond directly to the client.  With this type of traffic pattern, your load balancer is essentially only taking incoming traffic.  This will significantly increase its ability to handle traffic.  The outgoing traffic back to the client will be shared amongst your web-nodes.  You’ve just allowed your cluster to handle a much larger scale of traffic, since your traffic is now spread against your cluster.</p>
<p><strong>Helpful Notes</strong></p>
<ul>
<li>ipvsadm &#8211; this command will tell you what LVS solutions are currently running. While the server is listening on port 80, it will not show up in netstat. It&#8217;s simply forwarding that port traffic to another server. The web server itself will respond directly to the client.</li>
<li>The heartbeat solution used in the configuration is pulse and not heartbeat like we would normally use. It has a slightly irregular behavior compared to heartbeat. While there is a master and slave named in the configuration file, the Master Load Balancer will not capture the IP whenever it is online. Whoever has the shared IP at the time is the true master, and there will not be a change unless there is a failure.</li>
<li>piranha has a gui editor.  You can turn it off, you won&#8217;t need to use it.</li>
<li>You’ll want to move sessioning to your database or a shared disk solution, if you haven’t already.</li>
<li>Turn off IPtables until you’ve got everything working.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rackspace.com/blog/installing-and-configuring-lvs-tun/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Simple Load Balancing on Cloud Servers</title>
		<link>http://www.rackspace.com/blog/simple-load-balancing-on-cloud-servers/</link>
		<comments>http://www.rackspace.com/blog/simple-load-balancing-on-cloud-servers/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 17:52:11 +0000</pubDate>
		<dc:creator>Brandon Woodward</dc:creator>
				<category><![CDATA[Tips for Devs and Sys Admins]]></category>
		<category><![CDATA[load balancing]]></category>

		<guid isPermaLink="false">http://www.rackspacecloud.com/blog/?p=3517</guid>
		<description><![CDATA[By Brandon Woodward, RHCE In this article, I will walk you through creating a simple software load balancer using our Cloud Servers product. This is an entry-level job using simple readily available packages from any of the distributions repositories. I’ll be using Apache as our load balancer (Apache can be used as many things including [...]]]></description>
				<content:encoded><![CDATA[<p>By Brandon Woodward, RHCE</p>
<p>In this article, I will walk you through creating a simple software load balancer using our <a href="http://www.rackspacecloud.com/cloud_hosting_products/servers" target="_blank">Cloud Servers</a> product. This is an entry-level job using simple readily available packages from any of the distributions repositories. I’ll be using <a href="http://www.apache.org/" target="_blank">Apache</a> as our load balancer (Apache can be used as many things including a load balancer) in conjunction with the Apache module mod_proxy and mod_proxy_balancer. Both are available through <a href="http://www.centos.org/" target="_blank">CentOS</a> and I&#8217;ll be using this as my base install.</p>
<p>The main thing that I want you to take out of this is that you can use Cloud Servers to scale horizontally. You can only scale a server vertically (i.e. more memory, processor) as a web head so far and eventually you won’t receive better performance from a faster server. This is when you need horizontal expansion and will need to add drone servers behind a smart host, each working a piece of workload.</p>
<p><strong>Prerequisites </strong></p>
<h4><strong>Hardware </strong></h4>
<p>We are going to use a total of 3 boxes to start out with:</p>
<p>•    One 256M Cloud Server to be used as the load balancer<br />
•    Two Cloud Servers to be used as dumb web heads</p>
<h4><strong>Software </strong></h4>
<p>The software for all three servers will be the same technically where they will be running the same packages. We&#8217;ll throw in only two software groups.</p>
<p>•    Update your system to all the newest goodies:</p>
<p><span style="color: #000000;"><strong><img class="alignnone" title="Load Balance 6" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/Load%20Balance%206.png" alt="" width="125" height="27" /><br />
</strong></span></p>
<p>•    Apache and all its goodies, CentOS makes this ultra simple with the groupinstall feature:</p>
<p><span style="color: #000000;"><strong><img class="alignnone" title="Load Balance 7" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/Load%20Balance%207.png" alt="" width="259" height="25" /><br />
</strong></span></p>
<p>•    I will be installing links to a text based web browser in case we ever need to check that a particular web head is displaying the page it is supposed to be behind the load balancer (this is optional):</p>
<p><img class="alignnone" title="Load Balance 9" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/Load%20Balance%209.png" alt="" width="323" height="30" /><span style="color: #000000;"><strong><span style="color: #000000;"><br />
</span></strong></span></p>
<p><strong>Server Configuration </strong></p>
<h4><strong>Web Servers </strong></h4>
<p>This is going to be the easiest part of the entire configuration. Since the webheads are really just drones, they&#8217;re only going to be doing grunt work and need no special configurations. That’s right, you don&#8217;t even open the httpd.conf file, just put a file called index.html in /var/www/html/index.html. In this file you can put any distinguishing characteristics you want. I put &#8220;It works, you are looking at WebHead #&#8221; where # is the numerical identifier of that particular webhead.</p>
<h4><strong>Load Balancer </strong></h4>
<p>This is the tricky part of the operation. I&#8217;ll walk through each step and then bring it together at the end for you so you know what the end product should be. All of the configurations that we are going to go through should be placed at the bottom of /etc/httpd/conf/httpd.conf in a standard Virtual Host to work.</p>
<h4><strong>Unwanted Requests </strong></h4>
<p>We are not working as a Forwarding Proxy (better known as an Open Proxy, and it’s bad news as it allows people to mask their identity by using your server to view web pages for them, it has its uses but not in this scenario). Turning off ProxyRequests will help avoid any unwanted traffic.</p>
<p><strong><span style="color: #000000;"><img class="alignnone" title="Load Balance 5" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/load_balance_5.png" alt="" width="153" height="28" /><br />
</span></strong></p>
<h4><strong>The Balance </strong></h4>
<p>In this part of the Virtual Host we will be naming our web heads and declaring how we will be balancing. The BalanceMember directive is how you declare the webheads. Of course you can add as many as you would like, using these as templates. The ProxySet directive declares how you would like to balance. We&#8217;re going to use a &#8220;byrequest&#8221; balancing algorithm which is the same as a Round Robin, so for each new request you will get a new webhead. The order is sequential and although there are better and smarter algorithms out there, this is the easiest to configure and you need no knowledge of networking theory. All of this will be wrapped in &lt;Proxy&gt; tags, which is how Apache knows to send it to mod_proxy. The &#8220;balancer://mycluster&#8221; identifier is only an identifier although you could technically call it what you want as long as you put the &#8220;balancer://&#8221; prefix.</p>
<p><strong>Keep in mind you will want to contact your webheads from the load balancer with their private IPs (this will keep your bandwidth charges down to a minimum by keeping all inter server communication between on the private network, where bandwidth is free).</strong></p>
<p><img class="alignnone" title="load balance 2" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/Load_Balance_2.png" alt="" width="330" height="137" /></p>
<h4><strong>Balance Manager</strong></h4>
<p><em>Optional Step</em><br />
This is a tool packaged with the mod_proxy_balancer tool and it allows you to make configurations from a gui tool through the web browser. It is viewable at &#8220;http://domain.com/balancer-manager.” Keep in mind that these changes die after you restart Apache. I won&#8217;t go over how to use this tool, but it is available to you.</p>
<p><img class="alignnone" title="Load_Balance_3" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/load_balance_3.png" alt="" width="245" height="53" /></p>
<h4><strong>ProxyPass</strong></h4>
<p>This is the last part of the configuration and just adds the situations that will need to be proxied. We don&#8217;t want to proxy the balancer-manager, but we do want to proxy everything else.</p>
<p><img class="alignnone" title="Load_Balace_4" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/load_balance_4.png" alt="" width="270" height="49" /></p>
<p><strong>Summary</strong></p>
<p>If you have all this in your httpd.conf on your load balancer Cloud Server and start up Apache, you should be able to view your domain name that is properly pointed to your load balancer. When you hit refresh it should hop between your two webheads saying, &#8220;It works, you are looking at WebHead 1&#8243; or &#8220;It works, you are looking at WebHead 2.” Congratulations, you are now balancing.</p>
<p>What I have done for you is combine all the things we&#8217;ve learned into a helpful packaged VirtualHost. You just need to trade out all the necessary values that are specific to your configuration like the domain name and the IP addresses to your webheads. Also, there are some security additions that are explained in the comments; everything is commented so you don&#8217;t have to refer back to this article to make changes later.</p>
<p><img class="alignnone" title="Load_Balance" src="http://c0179631.cdn.cloudfiles.rackspacecloud.com/load_balance.png" alt="" width="447" height="647" /></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="float: right;" src="http://img.zemanta.com/zemified_e.png?x-id=cf5fbcb7-2de6-4f26-a7e9-4fddb0672ada" alt="Enhanced by Zemanta" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rackspace.com/blog/simple-load-balancing-on-cloud-servers/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Content Delivery Network via Rackspace Cloud Files: c3414940.r40.cf0.rackcdn.com

 Served from: www.rackspace.com @ 2013-05-21 21:36:08 by W3 Total Cache -->