For example, for haproxy (layer 7) load balancing, you only need to configure the "real servers" or "backends" behind the VIP (i.e., cluster IP). E.g.:

listen smtp
        mode tcp
        balance roundrobin
        server smtp1 check
        server smtp1 check

However, with lvs (layer 4), I'd need to either:

  1. Set the lvs machine as the router to implement "NAT Routing"
  2. The lvs machine and the backends have the VIP configured with some ARP mods on the backends

How does layer 7 load balancing manage to do this without the more involved configuration? Am I misunderstanding or missing something fundamental here?


With LVS, your network traffic essentially goes from the client directly to your backend server. Having a third host (semi-transparently) involved here is not a normal network configuration, which is why it's fairly difficult to implement.

With haproxy, your network traffic goes from the client to haproxy, then haproxy to the server. As far as the server is concerned, haproxy is just another client. This is a normal networking setup, so there's no network layer complexity to setup (though there is Layer 7 complexity, such as X-Forwarded-For headers). It also means that your haproxy machine is a SPOF, and needs to be able to handle the total traffic to your website.

| improve this answer | |

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.