我们正在尝试在HAProxy和HAProxy之后配置我们的Socket.io套接字服务器,我们正在使用Google Cloud Load Balancer,因此HAProxy不是单点故障。正如https://medium.com/google-cloud/highly-available-websockets-on-google-cloud-c74b35ee20bc#.o6xxj5br8中的帖子所述。也如下图所示。
在Google云负载均衡器上,我们正在使用带有代理协议的SSL代理进行TCP负载均衡。
HAProxy配置为使用Cookie,以便客户端始终连接到同一服务器。但是,由于我们所有客户端系统都可能无法使用cookie,因此我们决定在HAProxy中将负载均衡算法用作source
。这是HAProxy配置
全球 log / dev / log local0 log / dev / log local1通知 chroot / var / lib / haproxy stats socket /run/haproxy/admin.sock mode 660 level admin 统计超时30秒 maxconn 16384 tune.ssl.default-dh-param 2048 用户haproxy haproxy集团 守护程序
# 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 ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
mode http
log global
option httplog
option http-server-close
option dontlognull
option redispatch
option contstats
retries 3
backlog 10000
timeout client 25s
timeout connect 5s
timeout server 25s
timeout tunnel 3600s
timeout http-keep-alive 1s
timeout http-request 15s
timeout queue 30s
timeout tarpit 60s
default-server inter 3s rise 2 fall 3
option forwardfor
frontend public
bind *:443 ssl crt /etc/ssl/private/key.pem ca-file /etc/ssl/private/cert.crt accept-proxy
maxconn 50000
default_backend ws
backend ws
timeout check 5000
option tcp-check
option log-health-checks
balance source
cookie QUIZIZZ_WS_COOKIE insert indirect nocache
server ws1 socket-server-1:4000 maxconn 4096 weight 10 check rise 1 fall 3 check cookie ws1 port 4000
server ws2 socket-server-1:4001 maxconn 4096 weight 10 check rise 1 fall 3 check cookie ws2 port 4001
server ws3 socket-server-2:4000 maxconn 4096 weight 10 check rise 1 fall 3 check cookie ws3 port 4000
server ws4 socket-server-2:4001 maxconn 4096 weight 10 check rise 1 fall 3 check cookie ws4 port 4001
然而,与旧的单服务器系统相比,这会给我们大约5%的客户端带来连接错误。有什么建议吗?
编辑:连接错误意味着客户端无法连接到套接字服务器,并且socket.io客户端正在抛出连接错误。
提前致谢。