WebSockets和负载平衡,瓶颈? [英] WebSockets and Load Balancing, a bottleneck?

查看:126
本文介绍了WebSockets和负载平衡,瓶颈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有一堆充当WebSocket无人机的系统以及在这些无人机前面的负载均衡器时.当WebSocket请求进入LB时,它将选择WebSocket无人机,并建立了WebSocket. (我在ELB使用SSL终止的AWS ELB tcp SSL)

When having a bunch of systems that act as WebSocket drones and a Load Balancer in front of those drones. When a WebSocket request comes into the LB it chooses a WebSocket drone, and the WebSocket is established. (I use AWS ELB tcp SSL-terminated at ELB)

问题: 现在创建的WebSocket是通过LB还是LB将WebSocket请求转发到WebSocket无人机,因此客户端和WebSocket无人机之间存在直接链接?

Question: Now does the created WebSocket go through the LB, or does the LB forward the WebSocket request to a WebSocket drone and thus there is a direct link between client and a WebSocket drone?

如果WebSocket连接通过LB,则这将使LB成为巨大的瓶颈.

If the WebSocket connection goes through the LB, this would make the LB a huge bottleneck.

删除LB并向客户提供WebSocket无人机的直接IP可以绕过此瓶颈,但需要自己创建此逻辑,我打算这样做(取决于此问题的答案).

Removing the LB and handing clients a direct IP of a WebSocket drone could circumvent this bottleneck but requires creating this logic myself, which I'm planning to do (depending on this questions' answers).

我对此的想法是否正确?

So are my thoughts on how this works correct?

推荐答案

AWS ELB作为LB

查看了可能重复的内容通过 Pavel K ,我得出结论,WebSocket连接将通过AWS ELB,如下所示:

After looking at the possible duplicate suggested by Pavel K I conclude that the WebSocket connection will go through the AWS ELB, as in:

Browser <--WebSocket--> LB <--WebSocket--> WebSocketServer

这使ELB成为瓶颈,我想要的是:

Browser <--WebSocket--> WebSocketServer

ELB仅用于为客户端提供可用WebSocketServer的主机名/IP.

Where the ELB is only used to give the client a hostname/IP of an available WebSocketServer.

DNS为LB

可以通过在DNS级别上进行平衡来避免上述问题,如

The above problem could be circumvented by balancing on DNS-level, as explained in the possible duplicate. Since that way DNS will give an IP of an available WebSocketServer when ws.myapp.com is requested.

缺点是,这需要通过上下更改WebSocketServer来不断更新DNS(如果您的应用程序具有弹性,那么这甚至会成为一个问题).

Downside is that this would require constantly updating DNS with up/down WebSocketServer changes (if your app is elastic this becomes even more of a problem).

自定义磅

另一种选择是创建一个自定义的LB,该LB不断监视WebSocketServer,并在客户端请求时返回可用WebSocketServer的IP.

Another option could be to create a custom LB which constantly monitors WebSocketServers and gives back the IP of an available WebSocketServer when the client requests so.

缺点是客户端需要执行单独的(AJAX)请求以获取可用WebSocketServer的IP,而对于AWS ELB,负载平衡是隐式发生的.

Downside is that the client needs to perform a separate (AJAX) request to get the IP of an available WebSocketServer, whereas with AWS ELB the Load Balancing happens implicitly.

结论

选择更好的邪恶.

这篇关于WebSockets和负载平衡,瓶颈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆