Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In Apache, mod_proxy_balancer supports load balancing in the easiest way.

Please refer to Easy HTTP load balancing with Apache. When the request is processed by workers (load balancing nodes), does it come to a load balancing server and then go to the client, or does it go directly from workers?

Example:
Method 1: Web Client -> Load Balancer -> Worker -> Load Balancer -> Web Client

OR

Method 2: Web Client -> Load Balancer -> Worker -> Web Client

What is happening in Apache load balancer?

share|improve this question

migrated from stackoverflow.com Sep 22 '12 at 2:05

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Even when returning, the data must go through the proxy server, as it's the server that holds the TCP connection of the client, and is supposed to send the answer through it.

Solution without proxy server working on the back path do exist, but those are much harder to implement correctly (dirty TCPIP/iptables tricks are usually involved).

EDIT: good solution without proxy server:

"Clean solution" that would magically forward TCP SYNs and would offload everything else from the load balancer is probably a dream, and I'm not aware of any such thing.

Instead, there are two commonly used approaches:

- DNS load balancing: have more servers on multiple publicly accessible IP addresses, specify more A entries for your website, possibly make your DNS server shuffle the answer to add randomness. Works perfectly on many commercial installations. Pros: simple, Cons: "breakable", and you need public IP space.

- Firewall-only load balancing: There's most probably a single router that handles all your traffic anyway, so adding a few firewall rules on it usually doesn't harm actual performance. The thing you're looking for (on linux) is using the iptables' DNAT target, and some kind of "random" or "hashing" match. I personally use something like this on several installations:

iptables -t nat -A PREROUTING -d 11.22.33.44 -p tcp --dport 80 -m random --average 50 -j DNAT --to 192.168.0.2
iptables -t nat -A PREROUTING -d 11.22.33.44 -p tcp --dport 80 -j DNAT --to 192.168.0.3

Replace 11.22.33.44 with your public IP address and 192.168.x.x with your servers. Don't forget to modify --average values.

Pros: whole solution looks like a single server from outside, loadbalancing is unbreakable by DoSing a single server, etc. Cons: you want to have the router and all the servers at one spot.

share|improve this answer
    
That makes sense, As the client makes tcp/ip connection with proxy and not with worker. I think, when we have more clients and more worker, this will bring burden on the proxy and finally makes it slow. is there any way, I can only forward the request from client to worker and from there on Worker takes care of it. Please share more information, on how to do it. –  Mani May 15 '12 at 4:00
    
edited to the answer :] –  exa May 22 '12 at 18:43
    
Thanks for your information. We are using apache load balancer now. –  Mani Jun 19 '12 at 4:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.