I was looking at using HAProxy and Nginx for load balancing, and I had some questions:
Thanks
The major benefit of Nginx is that it can be used for many other things including serving static files or running dynamic apps. On the other hand, if you don't need a web server and would rather a load balancer that provides much more information by default then HAProxy might be the right choice.
The system under test – HAProxy or NGINX – acted as a reverse proxy, establishing encrypted connections with the clients simulated by wrk threads, forwarding requests to a backend web server running NGINX Plus R22, and returning the response generated by the web server (a file) to the client.
Envoy came out as the overall winner in this benchmark. It had the highest throughput in terms of requests per second. It's interesting that Envoy's throughput was several times higher than others. While HAProxy narrowly beat it for lowest latency in HTTP, Envoy tied with it for HTTPS latency.
HAProxy, lighttpd, Traefik, Caddy, and Envoy are the most popular alternatives and competitors to 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.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With