当服务器场中的一台服务器closures时,haproxy不会负载平衡

我有三个后端服务器使用HAProxy进行负载平衡

当所有3个这些都是我看到每个服务器Id(1,2,3)连续在HTTPS响应。 IE 1,2,3,1,2,3。 正如所料。

但是,如果我拿一个后端服务器,我只能看到一个服务器ID重复。

即如果我把服务器1下来,然后我只能看到服务器ID 2(2,2,2,2 …),当我应该看到服务器ID的2,3(2,3,2,3,2,3 … ..)

我已经尝试了最简单和循环平衡,并且都performance出相同的行为

为什么HAProxy以这种方式performance? 如何修改我的HAProxyconfiguration以在剩余的活着的后端服务器之间进行负载均衡?

HA代理版本是1.6.9。 HA代理服务器是Ubuntu 14.04。

所提供的HTTP是一个通过HTTPS返回一些JSON的API。 它是一个平静的API,所以不需要或不需要会话持久性。

haproxy的configuration如下。

global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon maxconn 3072 # Default SSL material locations ca-base /etc/ssl/certs crt-base /etc/ssl/private # Default ciphers to use on SSL-enabled listening sockets. # For more information, see ciphers(1SSL). This list is from: # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH$ ssl-default-bind-options no-sslv3 defaults log global mode http option httplog option dontlognull option dontlog-normal option redispatch retries 3 maxconn 3072 timeout connect 5000 timeout client 10000 timeout server 10000 frontend apis-frontend bind xxxx:443 ssl verify none crt /etc/haproxy/xxx mode http option forwardfor default_backend apis backend apis balance leastconn mode http option httpchk GET / server 1 xxxx:443 ssl verify none check server 2 xxxx:443 ssl verify none check server 3 xxxx:443 ssl verify none check listen stats bind *:8181 mode http stats enable stats uri / stats realm Haproxy\ Statistics stats auth xx 

编辑:添加统计信息。

 pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime, apis-frontend,FRONTEND,,,0,2,3072,24,9118,10021,0,0,19,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,4,,,,0,24,0,19,0,0,,0,6,43,,,0,0,0,0,,,,,,,, apis,mt-wol-vlx-vps-01,0,0,0,1,,12,4863,3240,,0,,0,0,0,0,UP,1,1,0,1,0,12097,0,,1,3,1,,12,,2,0,,2,L7OK,200,36,0,12,0,0,0,0,0,,,,0,0,,,,,39,OK,,0,1,1,29, apis,mt-lon-vlx-vps-01,0,0,0,1,,12,4255,3228,,0,,0,0,0,0,UP,1,1,0,0,0,12097,0,,1,3,2,,12,,2,0,,2,L7OK,200,23,0,12,0,0,0,0,0,,,,0,0,,,,,39,OK,,0,1,1,5, apis,mt-cov-uks-vps-01,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,1,1,12094,12094,,1,3,3,,0,,2,0,,0,L4TOUT,,2001,0,0,0,0,0,0,0,,,,0,0,,,,,-1,,,0,0,0,0, apis,BACKEND,0,0,0,1,308,24,9118,6468,0,0,,0,0,0,0,UP,2,2,0,,0,12097,0,,1,3,0,,24,,1,0,,3,,,,0,24,0,0,0,0,,,,,0,0,0,0,0,0,39,,,0,1,1,33, stats,FRONTEND,,,1,4,3072,10,3811,169181,0,0,5,,,,,OPEN,,,,,,,,,1,4,0,,,,0,1,0,4,,,,0,9,0,5,0,0,,1,3,15,,,0,0,0,0,,,,,,,, stats,BACKEND,0,0,0,0,308,0,3811,169181,0,0,,0,0,0,0,UP,0,0,0,,0,12097,0,,1,4,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,0,,,0,0,0,18, 

编辑:在不同浏览器中的负载平衡行为

在请求从不同的iptesting。 我注意到第二个ip负载平衡如预期。 然后,我尝试从第一个IP,但使用不同的浏览器边缘和Firefox。 如预期的边缘和Firefox的负载平衡。

然而,原来的浏览器铬仍然坚持一个后端服务器。 即使closures所有的铬窗口并重新启动铬

经过进一步testing后,只有使用Google的Chrome浏览器才会显示所显示的行为。 为什么铬显示这种行为是不确定的。

观察到的行为不是一个HAProxy问题。

这与其他浏览器和其他客户多次testing。 最后的certificate是几个小时的现场服务。

上面的HAProxyconfiguration现在已经运行了几个小时,并且在三台服务器之间公平地分配stream量。 这是从我们的logging服务器ID的DBloggingcertificate的。 在几个小时的时间内,每个服务器被分配相同数量的请求,在大约4,500个请求的+ – 50之内。

更重要的是,鉴于原来的问题,在其中一台服务器出现故障的情况下,它也继续公平分配。 我们的数据库logging再次certificate哪些logging服务器ID。 经过15分钟的测量,在我们的数据库logging中可以看到清晰的平衡服务器ID的模式。

一个尖刻的提醒,devisetesting,以指出问题所在,然后假设问题在于你不太了解的解决scheme的部分。

感谢你为实现这个梦想所做出的许多回应。