HAProxy vs. Nginx HAProxy vs. Nginx nginx nginx

HAProxy vs. Nginx


haproxy is a "load balancer" it doesn't know to serve files or dynamic content. nginx is a web server capable of many interesting things. if you only need to load balance + HA some third web server then haproxy is enough. if you need to implement some static content or some logic in routing of the requests before terminating them on a third server then you may need nginx.

The reason you can see haproxy+nginx on the same host is that it allows you to bring down single nginx instances while haproxy continues to serve requests from other hosts. Imagine having a RR DNS using A records:

myapp.com IN A 1.1.1.1myapp.com IN A 1.1.1.2

where 1.1.1.1 and 1.1.1.2 are two hosts with haproxy+nginx configured to load balance between them. Now for some reason your 1.1.1.1's nginx goes down. The browsers that come to 1.1.1.1 are still being served by haproxy on it which in turn gets data from 1.1.1.2's nginx.

hope it helps


HAProxy is definitely the better, more fully featured loadbalancer (compared to the free nginx, not nginx plus (but one could argue that as well).

One thing that HAProxy sadly still can't do is generic UDP connections. So we used HAProxy and nginx on our logging lbs. But HAProxy released support for syslog/udp in 2.3 so we are about to change that. :)


NGINX next to HAProxy looks like a 2CV next to a Tesla...

Benefits HAProxy:

  • Provides a comprehensive list of 61 different metrics. See section 9for a full list of available statistics

  • The status page is much more detailed and user-friendly as compared to Nginx’s

  • Easily able to integrate with third-party monitoring services (e.g. Datadog)
  • IPV6, PROXY PROTOCOL, TRANSPARENT PROXY, SSL & SNI, HTTP2, API, LUA Scripting, RDP connection broker, Stick tables, multi-node session replication, DDOS & DOS protection...

Drawbacks HAProxy:

  • Does not provide other features that Nginx offers such as web server capabilities

Benefits Nginx:

  • Since Nginx is capable of doing much more than load balancing it is a much more versatile solution
  • Useful if you require a load balancer as well as a web server with advanced caching ability, and more
  • There is a community-developed module for greater statistic gathering than what is offered by default

Drawbacks Nginx:

  • Only provides 7 stat metrics which represent all sites on the server. There is no individual, per-site metrics available
  • The status page is not user-friendly nor does it provide many details
  • Very limited third-party monitoring integration possibilities