4 ms·
Why do you choose HAProxy over Ngxinx? It's sounds like you love it, and I have had no experience with HAProxy. So I'm curious about the reasons you love it.
by apple4ever 6y ago
Why do you choose HAProxy over Ngxinx?
It's sounds like you love it, and I have had no experience with HAProxy. So I'm curious about the reasons you love it.
(Just to be clear this is a sincere question to learn since tone is hard to express clearly with text.)
- TimWolla 6y agoI gave my reasoning back on the HAProxy 2.0 announcement: https://news.ycombinator.com/item?id=20198232 https://news.ycombinator.com/item?id=20198232
- apple4ever 6y agoPerfect thank you! This is why I love HN. I ask a good question and get a lot of great feedback!
- lukeqsee 6y agoAs a load balancer, NGINX is subpar in almost every feature comparison, especially at the open-source (free to use) tier. HAProxy gives you the following that are musts for load balancing (in my opinion), that NGINX does not, at least not easily: 1) A HTML (or JSON) stats page that precisely and completely tells you what’s going on at a high-level. A visit to this during outages is often all that’s required. 2) Support for DNS (and other) discovery mechanisms in a flexible way. (This is paid in NGINX) 3) Active health checks (also paid in NGINX) 4) The ACL system, while somewhat difficult to learn, is amazingly powerful. 5) Flexible L7 retries are brilliant. We replaced NGINX with HAProxy and eliminated a whole class of bugs, micro-outages, and annoyances just by following HAProxy’s best practices. I still use NGINX when I need a static web file server, though. :)
- apple4ever 6y agoWow that is very helpful. I am going to take a look now!
- raghava 6y agoHAProxy - traffic shaping { load-balancing, req-throttling, health-checks } nginx - { static file serving, good proxy for python/ruby apps, req manipulation with advanced scripting capabilities via lua engine through open-resty [mirroring, WAF(naxsi), url rewriting etc] } A combo of haproxy + nginx would always bring good delight for many practitioners.
- wtarreau 6y agoThis is actually what I often recommend and often encounter in field: haproxy for LB, varnish serving as a smart cache, and nginx for the applications+static file serving. All 3 components are free, combine extremely well because they've grown together, and are extremely efficient. This is important in virtualised or containerized environments where you want to save resources to minimize response time and leave the CPU for the applications. Of course each of them can do a little bit of the other ones' job. This is fine, it allows easier initial deployments, but as your site grows, whichever you initially start with, you'll always end up installing the two other ones to constitute the most robust stack ever. And it's easy to insert one next to the others without having to break everything, which further adds to the fun.
- lukeqsee 6y agoYes. We use all three at different points of the stack for different purposes. It's great.
- bpicolo 6y agoOne good reason is that HAProxy doesn't payment gate a bunch of the baseline features. I'm still surprised that NGINX doesn't come with active healthchecks in the free version - baseline feature for a load balancer in the world of treating computers as cattle. HAProxy is such a great example of software that does what you expect, generally.
- takeda 6y ago> HAProxy is such a great example of software that does what you expect, generally. It's also rock solid and battle tested. I don't think I ever observed crash. It's typically one of tools that once you configure correctly it works for years without issues.
- toast0 6y ago> I don't think I ever observed crash. It got a lot better quickly, but running with thread was crashy with a lot of threads. I don't remember crashes with single threaded/forking mode though, and I ended up with a forking config when I was setting something up at my last job.
- takeda 6y agoWhy you chose Nginx over HAProxy? I see a lot of people preferring Nginx, but I can't understand why they are so fascinated about it and try to squeeze it where it has no place. Nginx is just a web server that has some load balancing functionality, it is sub par with HAProxy. I never seen people saying why are you using HAProxy instead of Apache, but Nginx load balancing functionality is closer to Apache than HAProxy.
- apple4ever 6y agoI choose it because I have a lot of experience with Nginx, and none with HAProxy. So I set it up as a LB, and it worked for my needs (at least from what I can tell). I will definitely checkout out HAProxy now.
- heipei 6y agoI think people choose nginx because it does everything decently, even if it can't beat HAProxy for load-balancing or Varnish for caching (at least the FOSS nginx). I run a small-to-mmedium size application with multiple upstream (local web app tier, remote asset servers) and some basic vhost and caching use-cases, e.g. cache specific paths with different cache keys than others, different cache behaviours and life-times, request rate limiting, some local file serving. nginx does everything I need, without any additional modules. I get close enough to zero-downtime deployments by using multiple backends and proxy_next_upstream, haven't needed active healthchecks for the upstreams yet. I have JSON access logs, so my dashboard about vhost activity is in Kibana now. There are a few juicy features missing (cache PURGE, proxy request coalescing, extended stub status endpoint, JSON error log). Not trying to fanboy, but I wouldn't introduce additional complexity into my stack by running haproxy + varnish + nginx just to get the best of each tool, not at my current scale.
- jedberg 6y agoI switched reddit from nginx to haproxy because nginx had a pathological problem where it would send 90% of the load to the first app server listed when there was a burst of requests (and 9% to the next, and .9% to the next and so on, leaving almost every app server idle). I'm sure they fixed the problem by now, but it was not a good look for a load balancer. HAProxy on the other hand has never failed me, and Wily (the creator) is super responsive if you have questions or need features.