How to: Simple load balancer setup for web servers

I finally put together a load balancing setup together this weekend, and I'm surprised it was this easy.

What you'll need is three servers, two web servers and one server for the load balancer. It's not recommended that you only use one load balancer since it's a single point of failure (SPOF) but I only had one extra server on hand. For this tutorial, I used Debian Lenny.

 

First thing's first, download and install pound on your load balancer. 

 
 

apt-get install pound

 

Once you've done that, head over to /etc/pound and edit your pound.cfg file accordingly. Here's an example for the web servers:
 
 

   
Service

#first web server
BackEnd
Address 192.168.0.114
Port 80
End

#second web server
BackEnd
Address 192.168.0.116
Port 80
End

 End
End   

 Also be sure to set your ListenHTTP address and port.

Now edit your /etc/default/pound file and change startup=0 to startup=1

Start pound up with /etc/init.d/pound start If everything is configured properly, check out http://1.2.3.4:8080 (or whatever IP and port you put in your pound.cfg)
Half the time, the requests should go to Server A while the other half goes to Server B (you can configure this). For anything else, check out the man page here or type man pound
 

Luckily, my file server is running NFS and SAMBA, so I can have the same content on each web server. I couldn't completely get NFS working on Windows Server 2008 (which is on one of the web servers, ugh) so I mapped a SAMBA shared as a network drive and that seemed to work. 

 That's the end of this short tutorial, but keep in mind there's more things you can do with pound. You can set up chroot jails, HTTPS balancing and way more. Any comments or ideas are appreciated.

 

Последний Раз


Photo by psilver
I'll skip the whole 'I haven't posted for two weeks' intro. 

It's only October and it already snowed, a couple of inches and it's still here. Mornings are sure colder.

I finally put together my new fileserver, and up  from my one harddrive server before. I was going to do a RAID1 configuration, but instead went back to a normal partitioning setup (XFS on the secondary HDD for the files). Recieved another computer the other day, so I'm at a total of 7 servers.

I was planning on installing Darwin (hehe) on one of the faster ones, but I can't get this damn DVD is fried (for whatever reason). I'm hoping that it has CPU instructions for SSE2/3.

ICT (tech) class has been upped a bit for me, I ended up telling the teacher that I'm a Linux zealot. I guess he had never got "a peer to peer network" working (as in SMB shares), so he handed me an Ubuntu 7.10 CD.  Everything was working fine until something messed up with the first computer. It was complaining about libc6 (which was installed), and it couldn't install anything via dpkg or apt-get. I'll have to find my 9.04 compact diiiiiisc.

TCP is back up on the Torrentino tracker, since it was UDP only for a while. I checked about two weeks ago, and there was approximately 2000 concurrent connections, w00t! I ended up using opentracker, which is quite light on resources. The tracker runs at an amazing 450Mhz with 128MB's of RAM and runs incredibly well.

 

With the faster of the three servers used for other purposes, I'm stuck with two spare servers. What to do? If I recieved a lot of hits to Torrentino, I could set up a web server load-balancing scheme but it's not needed at the moment. The old fileserver is now a database server :)

Come to think of it, I have an old Pentium I that could be used as a syslog/notifications server. Management is key.

 

 

I have the urge to play Fallout 3.

Comments are appreciated ;)

 

Schematics

I've been profoundly confused on what to do with two new servers. At the moment, I have a total of three servers; a BitTorrent tracker, web server and NAS (NFS server). Now, what I was thinking was setting up a load balancing scheme using VS via NAT. Essentially, build one of the servers as a load balancer and turn the other one into a http node. The only problem with that is redundancy. Say if the load balancer fails for whatever reason, I'm screwed.

 

Same as my NAS, no RAID so if the HDD fails, I'm screwed again. Still, it would be a cool journey on getting a load balancing scheme set up...and working. That, and I just want to use all the ports on my 24 port switch. Then, depending on the load on the NFS server, I could run MySQL/Postgres on it for use with the web servers.

 

Gah I was trying to set up Liferay yesterday. Ugh, what a clusterfuck. Java make me want to shoot my self in the foot numerous times over. Though it might be worth it to run a wiki on the web servers, but the only problem with that (or indeed the whole server situation) is who's going to use it? Sure I'll be using it, but I'd only need one server in that case, not two. Oh well, I'll think of something.

 

I'm off to go watch a movie or something, I've been to unmotivated to code lately. I made a script that lets users upload a picture then send that URL to Twitter. Ugh I hate Twitter.