HAProxy vs. Nginx

佐手、 提交于 2019-12-03 10:01:56

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.1
myapp.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

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

Benefits HAProxy:

  • Provides a comprehensive list of 61 different metrics. See section 9 for 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!