在 Azure 中动态打开端口,负载均衡器是否足够智能,能够路由到正确的端口?
据我所知,我只能在 Azure 应用程序中打开 5 个端点,但是如果我动态打开这些端口怎么办?示例:我有一个带有
的 WorkerRole
,然后实例号 1 在 5 个可用端点之一中打开一个套接字在“.csdef”文件中声明,当连接转到“myapp.cloudapp.net”时...连接是否有可能转到没有侦听套接字的第二个实例?
我想是的,由于负载均衡器使用循环调度,它并不关心,它可以将连接转发到第二个,但我可能是错的。
问候。
As far as I know I can only open 5 endpoints in an Azure application, but what if I open those ports dynamically? Example: I have a WorkerRole
with an <Instances count="2" />
, then the instance number one open a socket in one of the 5 available endpoints I declared in the ".csdef" file, when a connection goes to "myapp.cloudapp.net" ... is there a chance that the connection goes to the second instance where there is not a listening socket?
I guess that yes, as the load balancer is using a round robin scheduling, it doesn't care and it could forward the connection to the second one, but I may be wrong.
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你猜对了。绝对没有办法将流量引导到特定实例,并且负载均衡器不知道您的实例是否正在运行侦听器。实现这一目标的唯一方法是让您的客户端应用程序(连接到 Windows Azure 部署的应用程序)不断重试,直到成功连接。
一般指导是 1) 让每个实例以相同的方式操作,在本例中为每个实例在端口上打开侦听器,2) 在添加到负载均衡器之前,在 OnStart() 方法中设置侦听器。
You guessed correctly. There's absolutely no way to direct traffic to a specific instance, and the load balancer has no idea if your instance has a listener running. The only way to make that work is for your client app (the one connecting to your Windows Azure deployment) to keep retrying until it gets a successful connection.
The general guidance is to 1) have each instance operate in the same manner, in this case opening listeners on the port for each instance and 2) setting up the listeners in the OnStart() method, prior to being added to the Load Balancer.
我猜你正在谈论一个InputEndpoint。但InternalEndpoints 不通过负载均衡器,可以由其他角色专门处理。因此,您可以在 Web 角色上设置一个处理程序,该处理程序可以将请求转发到您想要的特定辅助角色实例。
I guess that you are talking about an InputEndpoint. But InternalEndpoints do not go via the load balancer and can be addressed specifically by other roles. Therefore you could set up a handler on a web role that could forward the request to the specific worker role instance you want.