[erlang-questions] Unicorn-style load balancing in Erlang?
Thu Jan 3 01:53:44 CET 2013
Thanks for your reply.
I have used ranch before, and I think Unicorn is more than an acceptor
pool. In ranch, acceptor processes only do "accept", and then dispatch
the request to some worker process. I believe swarm works the same way
as a middleman.
In Unicorn, there's no separate worker (or acceptor) process; a
prefork process is both acceptor and worker. All the prefork processes
start out by calling "accept()" on the same listener socket. Then it's
the OS kernel who determines which "accept()" to awake, while others
>From the documentation of ranch:
> Our observations suggest that using 100 acceptors
> on modern hardware is a good solution, as it's big
> enough to always have acceptors ready and it's low
> enough that it doesn't have a negative impact on
> the system's performances.
What if there's no separate worker process? Will many number of
acceptor-and-workers have a negative impact as well?
On Thu, Jan 3, 2013 at 5:25 AM, Daniel Goertzen
> For bare acceptor pool libraries, take a look at...
> And I would bet that most significant socket server apps written in Erlang
> would use acceptor pooling of some sort.
> On Wed, Jan 2, 2013 at 10:09 AM, Xiao Jia <> wrote:
>> From http://www.erlang.org/doc/man/gen_tcp.html#accept-1:
>> > 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.
>> Does it mean that we can have Unicorn-style load balancing in Erlang?
>> If so, are there any existing servers or libraries making use of this
>> 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().
>> btw, I also posted this question on StackOverflow  but no active
>> responses there :-(
>> : http://unicorn.bogomips.org/
>> Xiao Jia
>> erlang-questions mailing list
More information about the erlang-questions