LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 June 11 2005

samer
Admin

Building a Linux Virtual Server

Building a Linux Virtual Server

NewsForge (an OSTG site) has an article that discusses the details of building a cluster for a virtual server - an environment where one can add and remove machines as needed, to account for high-traffic Web site of intensive database application: 'The main advantage of using LVS is that unlike Microsoft network load-balancing clusters, the LVS allows you to add a node running any operating system that supports TCP/IP to the cluster.

the article: click here

Offline

#2 June 11 2005

rolf
Member

Re: Building a Linux Virtual Server

nice
the system in the above link:

         clients
             |
  load balancing box
    |           |          |
server1 server2 server3

here you can see the load balancing box will redistribute connection fairly between server 1, 2 and 3.
But if the load balancing box fails everything will stop, right?
How do we protect ourself from that?

Offline

#3 June 11 2005

mahdoum
Member

Re: Building a Linux Virtual Server

gibberish

Offline

#4 June 11 2005

rolf
Member

Re: Building a Linux Virtual Server

mahdoum did you understand the concept at least?

Of course the command will be pure gibberish if you have no experience. Learning Linux is like learning chinese man.

But the concept is easy. Say you have a website mahdoum.com (I think you already have one). And you host the website on your own server. Ya3ne you have a good computer with a fast connection that you use as a server to host  your site.

Now because everybody likes the stuff you put on your site, you will have more and more visits. At one point, you'll have more visits per day then microsoft.com and your server will not be able anymore to handle the requests. It will become slow and occasionally drop requests.

One solution in this case is to set up a virtual server, that is you buy say 3 servers, but you set them up as a "virtual server", so that to the visitor it looks like only one server, but in reality it is 3 server working like one. Now how does that thing work?

easy you need say 3 servers and one load balancing box. What the load balancing box does is it receives requests to your site and redirect it to one of the 3 servers. This way the work gets fairly distrubuted over 3 servers (load balancing).
Now you may ask why does the load balancing box does not get overwhelmed too? That's because the job it does is very simple. It does not process the HTTP requests to your website, it just forwards them to one of the servers (by changing the destination IP for the requests and the source IP for the answers from the server).

Here is an illustration to make it clearer:

Load balancing box (LBB) IP: 192.168.0.1
Server1 (s1) IP: 192.168.0.2
Server2 (s2) IP: 192.168.0.3

LBB receives a TCP packet from 1.2.3.4 (the client) to 192.168.0.1 (the LBB)
LBB decide to forward the request to s1, so LBB changes the destination IP from the packet from 192.168.0.1 to 192.168.0.2 and sends it to s1.
s1 processes the request and sends an answer packet, ya3ne from IP 192.168.0.2 (its own IP) to IP 1.2.3.4 (the client).
LBB intercepts the answer, changes the source IP of s1 (192.168.0.2) to the IP of the LBB (192.168.0.1) and forwards the packet to the client.
This is actually a type of NAT, on linux they call it DNAT (destination NAT).

So in reality the client sends a request to 192.168.0.1 and receives the answer from 192.168.0.1. he doesnt know that his request was actually processed by s1 (192.168.0.2) or s2 (192.168.0.3) or s3 (192.168.0.3)

Note that works with almost any service, doesn't have to be for HTTP only, can be FTP, microsoft domain, mysql, etc... and of course it can also be more (or less) than 3 servers.

BTW it's ok if you dont read all this I dont care. Oh you already read it? damn!

Offline

#5 June 11 2005

mahdoum
Member

Re: Building a Linux Virtual Server

interesting, now it makes more sense ;) thanks.

Offline

#6 June 11 2005

Sadus
Member

Re: Building a Linux Virtual Server

learning Linux is not like learning chinese, easy on the ego rolf.

But if the load balancing box fails everything will stop, right?
How do we protect ourself from that?

I'm surprised that you heard of Load Balancing but missed to hear about Fail Over (a subject that is most of the time covered along with Load Balancing)

Offline

#7 June 11 2005

rolf
Member

Re: Building a Linux Virtual Server

OK, it's not like learning chinese, and yes I can be a bit pretentious. But it is definitely comparable to learning a new language. Learning all the commands and their various sytaxes, regular expressions, perl, bash...

But anyway, you seem to have misunderstood my question. I know a server cluster provides fail over as well, but my question was about the "load balancing box", that is the linux computer that is in charge of doing the load balancing. In the above setup, the "load balancing box" receives all connections and forwards them the servers, spreading the load. Hence it is a potential failure point.

My question is if there is any way to have failover for the "load balancing box", by having for example 2  such computers, with one acting as a load balancing box and the other as a backup that would kick in, take the IP of the load balancing box and continue the job if it should detect that the primary load balancing box is unreachable.

Well it seems I have answered my question myself. Should be easy to implement in a cron job that would ping the primary server and change the its IP if it times out.

Man I am so great that I should date myself.

Offline

#8 June 12 2005

Sadus
Member

Re: Building a Linux Virtual Server

How did i misunderstood your question if you replied to your own question?
Your representation of fail over is quite unprecise but that's the idea.

one should always think before asking :)

Offline

#9 June 13 2005

Sadus
Member

Re: Building a Linux Virtual Server

following up the thread, check this out, no need for load balancers anymore, everything can be done via: iptables

http://geminis.dyndns.org/wordpress/ind … -on-linux/

Offline

#10 June 13 2005

rolf
Member

Re: Building a Linux Virtual Server

Very nice. Easy, simple, reliable and spares you the cost of a PC.
The only downside is that it provides static (dumb) load balancing, that is new connections will not go to the least busy server and an idle server will not help and overloaded server in the same cluster. But you cant have everything.

Offline

Board footer