HAProxy混淆503错误

对HAProxy实例的所有请求中,将近有四分之一会发生503错误,尽pipe两个后端服务器是完全正常的,并且对各个服务器的重复检查完全不会返回任何错误。

PHP 5.3 FPM,Nginx,Ubuntu 10.10,HAProxy 1.4.8

以下是我的haproxy.cfg:

global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info maxconn 4096 #chroot /usr/share/haproxy user haproxy group haproxy daemon #debug #quiet defaults http log global mode http option httplog option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 errorfile 400 /etc/haproxy/errors/400.htm errorfile 403 /etc/haproxy/errors/403.htm errorfile 408 /etc/haproxy/errors/408.htm errorfile 500 /etc/haproxy/errors/500.htm errorfile 502 /etc/haproxy/errors/502.htm errorfile 503 /etc/haproxy/errors/503.htm errorfile 504 /etc/haproxy/errors/504.htm listen www 0.0.0.0:80 mode http balance roundrobin option redispatch cookie JSESSIONID prefix stats enable stats auth user:pass option httpclose option forwardfor option httpchk HEAD /health HTTP/1.0 server web1 xxxx:8080 weight 1 cookie web1 check inter 1000 server web2 yyyy:8080 weight 2 cookie web2 check inter 1000 

你的服务器有一个错误的IP地址,都有0.0.0.0! 这意味着连接将被转发到相同的IP haproxy接收到连接,所以我可以推断出你的两个服务器中的一个与haproxy在同一个主机上运行。

请修复并检查你的日志。 它可能不会修复你的503,但它会带你回到一个有机会工作的理智的configuration。 那么请检查您的日志,如果您仍然看到503,以便我们可以find为什么haproxy遇到问题。 大多数情况下503是由于无法连接到服务器造成的。 你给他们发送的连接比他们能接受的还要多。 在这种情况下,使用“服务器”线上的“maxconn”设置,这将使交通pipe制防止溢出。