【发布时间】:2014-11-23 21:25:48
【问题描述】:
我们的应用程序需要基于 cookie 的粘性会话,因此我们希望使用 HAproxy 来平衡传入 IIS 服务器场的流量。
我们正在使用以下配置,该配置似乎在实验室工作(循环工作正常并保留会话),但在超过 3k 并发用户的生产中应用时失败:
前端 Front_http
bind :80
mode http
default_backend backend_http
stats enable
capture cookie ASP.NET_SessionId len 32
maxconn 10000
前端 Front_https
mode http
default_backend backend_https
bind *:443 ssl crt /etc/haproxy/cert.pem
capture cookie ASP.NET_SessionId len 32
maxconn 10000
后端 backend_http
balance roundrobin
option forwardfor
stick-table type ip size 20k expire 5m
appsession ASP.NET_SessionId len 64 timeout 5m request-learn prefix
server Server_1 192.168.10.81:80 cookie Server_1
server Server_2 192.168.10.81:80 cookie Server_2
server Server_3 192.168.10.81:80 cookie Server_3
后端 backend_https
balance roundrobin
option forwardfor
stick-table type ip size 20k expire 5m
appsession ASP.NET_SessionId len 64 timeout 5m request-learn prefix
server Server_1 192.168.10.81:80 cookie Server_1 ssl verify none
server Server_2 192.168.10.81:80 cookie Server_2 ssl verify none
server Server_3 192.168.10.81:80 cookie Server_3 ssl verify none
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
从 HAProxy 1.5.8 文档中,我了解到基于 cookie 的粘性是通过命令“appsession”实现的,但我不了解其他命令所扮演的角色,例如“capture cookie”或“stick-table”,它们是否必要使用appsession时根本没有?任何人都可以帮助我了解它们的工作原理,并在您发现我们的配置有任何问题时提出建议。
【问题讨论】: