[英]What settings on HAProxy needed to work with AWS ALB (Application Load Balancer)?
Currently, we have 200 containers(several different applications) running in mesos-marathon cluster. 目前,我们在mesos-marathon集群中运行了200个容器(几个不同的应用程序)。 This is behind the HAproxy instances and works on HTTP/HTTPS protocol.
这是HAproxy实例的后面部分,适用于HTTP / HTTPS协议。
Internet --> AWS ELB --> HAProxy --> Docker containers Internet - > AWS ELB - > HAProxy - > Docker容器
Now we have a requirement to make one existing application to run on WEBSOCKET protocol. 现在我们需要使一个现有的应用程序在WEBSOCKET协议上运行。 We are thinking to add new AWS ALB to achieve this.
我们正在考虑添加新的AWS ALB来实现这一目标。 Hence the setup will be like
因此设置将是
(WebSocket)
Internet --> new AWS ALB --> HAProxy --> Docker containers
(HTTP/S)
Internet --> AWS ELB --> HAProxy --> Docker containers
What setting do we need to make so that HAproxy will work with current HTTP/S and also new WEBSOCKET? 我们需要做什么设置才能使HAproxy与当前的HTTP / S以及新的WEBSOCKET一起使用?
The server can handle 65,536 sockets per single IP address.
服务器每个IP地址可以处理65,536个套接字。 So the quantity can be easily extended by adding additional network interfaces to a server.
因此,通过向服务器添加额外的网络接口可以轻松扩展数量。 Meanwhile, it's extremely important to track how many connections present on a server.
同时,跟踪服务器上存在的连接数非常重要。 Once the limit is exceeded, you can have a lot of issues with other TCP connections (eg it's not possible to connect to a server via ssh).
一旦超出限制,您可能会遇到很多其他TCP连接的问题(例如,无法通过ssh连接到服务器)。 So it's a good idea to limit WS connections per node inside your application's code.
因此,在应用程序代码中限制每个节点的WS连接是个好主意。
To make HAProxy handle more than 65k connections we should pass through the next steps:: 要使HAProxy处理超过65k的连接,我们应该通过以下步骤::
Connect to your HAProxy instance via SSH and run following commands: 通过SSH连接到HAProxy实例并运行以下命令:
$> ifconfig eth0:1 192.168.1.1
$> ifconfig eth0:2 192.168.1.2
$> ifconfig eth0:3 192.168.1.3
This will add 3 virtual network interfaces to the instance. 这将为实例添加3个虚拟网络接口。
Configure HAProxy. 配置HAProxy。 Here is a section from haproxy.cfg file for 3 nodes accepting WS connections:
以下是haproxy.cfg文件中有3个节点接受WS连接的部分:
listen erlang_front :8888 听erlang_front:8888
mode http balance roundrobin timeout connect 1s timeout queue 5s timeout server 3600s option httpclose option forwardfor server xxxxx-1 192.168.0.1:8888 source 192.168.1.1 server xxxxx-2 192.168.0.2:8888 source 192.168.1.2 server xxxxx-3 192.168.0.3:8888 source 192.168.1.3
Now HAProxy can handle more than 65,536 WebSocket connections, and the limit of connections can be easily increased by adding virtual network interfaces. 现在,HAProxy可以处理超过65,536个WebSocket连接,并且可以通过添加虚拟网络接口轻松增加连接限制。 Also, it can establish new connections rather fast.
此外,它可以相当快速地建立新的连接。
Also Refer this Blog Post 另请参阅此博客文章
It sounds like you would benefit from using the new Network Load Balancer instead of the classic Elastic Load Balancer or the Application Load Balancer. 听起来您可以从使用新的网络负载均衡器而不是经典的Elastic Load Balancer或应用程序负载均衡器中受益。
The NLB can handle (according to AWS) 10's of millions of requests per second, and supports long-lived connections. NLB可以处理(根据AWS)每秒数百万的请求,并支持长期连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.