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?

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


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

What is happening in Apache load balancer?

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 -p tcp --dport 80 -m random --average 50 -j DNAT --to
iptables -t nat -A PREROUTING -d -p tcp --dport 80 -j DNAT --to

Replace 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.

  • 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, 2012 at 4:00
  • edited to the answer :]
    – exa
    May 22, 2012 at 18:43
  • Thanks for your information. We are using apache load balancer now.
    – Mani
    Jun 19, 2012 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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