Erlang中的接收者池和负载均衡? [英] Acceptor pooling and load balancing in Erlang?

查看:172
本文介绍了Erlang中的接收者池和负载均衡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.erlang.org/doc/man /gen_tcp.html#accept-1


值得注意的是,接受电话不必被发出
从套接字所有者进程。使用
仿真器的版本5.5.3及更高版本,可以从
不同的进程发出多个同时接受调用,这允许一个处理传入连接的接收器进程池

It is worth noting that the accept call does not have to be issued from the socket owner process. Using version 5.5.3 and higher of the emulator, multiple simultaneous accept calls can be issued from different processes, which allows for a pool of acceptor processes handling incoming connections.

(Q1)这是否意味着我们可以拥有独角兽 - Erlang中的负载平衡?

(Q1) Does it mean that we can have Unicorn-style load balancing in Erlang?

(Q2)如果是,是否有任何现有的使用此功能的服务器或库?

(Q2) If so, are there any existing servers or libraries making use of this feature?

(Q3) Unicorn在假设请求处理为的。在同样的假设下,是否可以通过在Erlang中组合接受者和工作者来获得更好的表现?

(Q3) Unicorn works under the assumption that request processing is fast. Under the same assumption, is it possible to gain better performance by combining acceptors and workers in Erlang?

对于那些不熟悉Unicorn的人来说,这是一个传统的UNIX prefork网络服务器。工作进程之间的负载平衡由操作系统内核完成。所有工作人员共享一组通用的侦听器套接字,并对它们进行非阻塞accept()。内核将决定哪个工作进程给一个套接字,如果没有任何接受(),工作人员将睡眠。对于单个侦听器套接字,我相信当工作进程阻止accept()并且操作系统内核决定竞争的结果时,它是一样的。

For those who are not familiar with Unicorn, it is a traditional UNIX prefork web server. Load balancing between worker processes is done by the OS kernel. All workers share a common set of listener sockets and does non-blocking accept() on them. The kernel will decide which worker process to give a socket to and workers will sleep if there is nothing to accept(). For a single listener socket, I believe it's the same when the worker processes do blocking accept() and the OS kernel decides the result of the "race".

推荐答案

我也在Erlang问题邮件列表中发布了这个问题。
正如Daniel Goertzen 所指出的那样,
在Erlang中有接受者池库,例如牧场群组

I also posted this question in the Erlang Questions mailing list. As pointed out by Daniel Goertzen, there are acceptor pool libraries in Erlang, such as ranch and swarm.


  • 牧场的工作方式与独角兽的不同之处在于,它只在许多进程中接受,然后将套接字传递给某个工作人员

  • ranch works differently from Unicorn in such a way that it only does "accept" in many processes, and then passes the socket to some worker process.

群集的工作方式与独角兽相同,意思是
接受者和工作人员合并。 (感谢LoïcHoguin 指出)
但是它们有点不一样,因为Swarm可以在
中接受一个新的套接字,与处理接受的套接字并行,而Unicorn
只能在接受的套接字处理后接受

The way swarm works is the same as Unicorn in the sense that the acceptor and worker is combined. (Thanks to Loïc Hoguin for pointing out) But they are a bit different because swarm can accept a new socket in parallel with the processing of the accepted socket, while Unicorn only accepts after the accepted socket is processed

我更喜欢群体风格,因为它是快速和缓慢的
请求,而Unicorn需要快速请求。

I prefer the swarm style since it's ideal for both fast and slow requests, while Unicorn requires fast requests.


而不是试图有效地服务慢客户端,独角兽
依靠缓冲反向代理来有效地处理缓慢的
客户端。

Instead of attempting to be efficient at serving slow clients, unicorn relies on a buffering reverse proxy to efficiently deal with slow clients.

独角兽不适合所有应用程序。独角兽针对
应用程序进行优化,这些应用程序是CPU /内存/磁盘密集型,并花费很少时间
等待外部资源(例如数据库服务器或外部
API)。

unicorn is not suited for all applications. unicorn is optimized for applications that are CPU/memory/disk intensive and spend little time waiting on external resources (e.g. a database server or external API).

独角兽对于Comet / reverse-HTTP / push应用程序
而言效率很低,其中HTTP连接花费大量时间空闲。

unicorn is highly inefficient for Comet/reverse-HTTP/push applications where the HTTP connection spends a large amount of time idle.

这篇关于Erlang中的接收者池和负载均衡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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