简体   繁体   English

负载均衡牛仔HTTP服务器

[英]load balancing cowboy http servers

how do you load balance identical cowboy http servers in the same cluster considering they have the identical listeners listening to the same port for requests? 考虑到它们具有相同的侦听器侦听相同端口的请求,如何在同一群集中平衡相同的牛仔HTTP服务器的负载? I don't think the usual round-robin approach for load balancing will work in this scenario since the listeners for each server are always active when the server starts. 我认为通常的循环负载均衡方法在这种情况下不起作用,因为每个服务器的侦听器在服务器启动时始终处于活动状态。 What am I missing here? 我在这里想念什么?

I think what your missing is that Cowboy doesn't register it's listeners globally across the cluster, it only registers them locally. 我认为您所缺少的是Cowboy不在整个集群中全局注册它的侦听器,而只是在本地注册它们。 Requests that are sent to node1 are processed with handlers running on node1 . 发送到请求node1与上运行的处理程序处理node1 Cowboy does not automatically form a cluster of servers across each of your connected nodes. Cowboy不会自动在每个连接的节点上形成服务器集群。 A Cowboy server will need to be started on each of your nodes and they will operate independently of each other. Cowboy服务器将需要在每个节点上启动,并且它们将彼此独立运行。

The best way to manage load balancing is to use a reverse proxy, such as Nginx, and have it redirect requests across your cluster. 管理负载平衡的最佳方法是使用反向代理(例如Nginx),并使其在整个群集中重定向请求。

If you need 'sticky sessions' that route requests to globally registered processes, then you should do a lookup (using global:whereis_name/1 ) from within the Cowboy handler and route the message across your cluster from there. 如果您需要将请求路由到全局注册进程的“粘性会话”,则应该在Cowboy处理程序中进行查找(使用global:whereis_name/1 ),然后从那里跨集群路由消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM