Thursday, February 3, 2011

HAProxy to the rescue? (multiple machines w. vhosts)

This is more of a 'best practice' or 'input appreciated' question.

Currently we manage about 5 webservers (in two DC's) that run Nginx for PHP websites. The plan is to redesign the setup so it is more manageable from an administrative point of view. One server is in a DC in another network, the rest in a single rack.

We sometimes have to move clients website(s) from one server to another and we would like to allow redundancy for certain clients etc. So a proxy seems a good start and any speed increase is highly welcomed, HAProxy seems like a good candidate for this both.

Our idea at this point is to make a single machine the HAProxy to everything else, so we can redirect anything anywhere, Seems smart to make that machine failover with something like CARP.

Any insights / input are highly appreciated.

  • I've setup a system like this in the past; for those who can't afford a full blown second datacenter & highend intelligent switching for failover, its not a bad option.

    There's one significant disadvantage to this, and thats if your paying for your bandwidth wherever the haproxy is hosted, you'll be paying double for bandwidth for connections that are proxied.

    Otherwise its a reasonable solution for those wanting to have loadbalancing or even just active failover.

    Another pretty popular loadbalancer/webserver/proxy is nginx, which might be worth looking at as well.

    Matt : Thanks! Regarding the bandwidth; a proxied request would serve (within the proxied data TTL that is) directly from the HAProxy machine without calling the actual serving machine, wouldn't it? So bandwidth only doubles upon a cache refresh request?
    GruffTech : Depends on your setup. I haven't used Haproxy as a caching server, however logically you would be correct.
    Matt : Mmhm. Looking into it I don't think HAProxy is up to the caching task, so that would mean either an extra layer behind HAProxy or a dedicated layer in front of it... which would in return need redundancy as well.
    GruffTech : Both Apache with Mod_Proxy and Mod_Cache, as well as NginX with Ncache (i think ncache is built into nginx now) should do the trick for both proxy and cache. From my experience both are faster then Ha_Proxy in terms of requests/second, and only apache has real disadvantages. nginx is a bit of a learning curve if you've not messed with it before, but its a beast of a server/proxy/cache once its implemented.
    Matt : Thanks GruffTech; I started looking into HAProxy because of http://affectioncode.wordpress.com/2008/06/28/another-comparison-of-haproxy-and-nginx/ The ncache is now in nginx core, and there is also fastcgi_cache now. I have not used them for actual caching but will try!
    From GruffTech

0 comments:

Post a Comment