HAProxy vs. Nginx

前端 未结 3 964
一生所求
一生所求 2021-02-06 23:12

I was looking at using HAProxy and Nginx for load balancing, and I had some questions:

  • Should I use JUST HAProxy over Nginx for the proxy server?
  • Is there
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 23:24

    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

提交回复
热议问题