简体   繁体   English

HAProxy上的哪些设置需要与AWS ALB(应用程序负载均衡器)一起使用?

[英]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的连接,我们应该通过以下步骤::

  1. Create a bunch of private IP addresses. 创建一堆私有IP地址。 To do it choose your Amazon Instance -> Actions -> Networking -> Manage Private IP Addresses. 为此,请选择您的Amazon实例 - >操作 - >网络 - >管理专用IP地址。 We added 3 IP addresses: 192.168.1.1, 192.168.1.2, 192.168.1.3. 我们添加了3个IP地址:192.168.1.1,192.168.1.2,192.168.1.3。 Just remember that the IP should be in the same sub-network as your real application server. 请记住,IP应与您的真实应用程序服务器位于同一子网中。
  2. 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个虚拟网络接口。

  1. 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.

相关问题 在AWS中使用Application Load Balancer(ALB)时出现混合内容问题 - Mixed content issue in using Application Load Balancer (ALB) in AWS 如何在 AWS 应用程序负载均衡器 (ALB) 端口转发中转发端口 - How to forward port in AWS Application load balancer (ALB) port forwarding 基于 AWS Application Load Balancer (ALB) 路径的路由未按预期运行 - AWS Application Load Balancer (ALB) path based routing not functioning as expected AWS 应用程序负载均衡器 (ALB) 基于主体的路由 - AWS Application Load Balancer (ALB) Body Based Routing AWS ALB(应用程序负载平衡器)-“ 502错误的网关”问题 - AWS ALB (Application Load Balancer) - “502 Bad Gateway” Issue HAproxy vs ALB 或任何其他负载均衡器使用哪一个? - HAproxy vs ALB or any other load balancer which one to use? Socket.IO 和负载均衡器 (ALB AWS) - Socket.IO and load balancer (ALB AWS) 使用 MySQL 在 AWS EC2 前部署 AWS 应用程序负载均衡器 (ALB) (3306) - Deploy an AWS Application Load Balancer(ALB) in Front of AWS EC2 with MySQL (3306) 为 alb 创建目标组(应用程序负载均衡器) - Creating a target group for a alb (application load balancer ) 使用 AWS Application Load-Balancer (ALB) 基于路径路由到外部资源 - Path-based routing to external resource with AWS Application Load-Balancer (ALB)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM