libev: notify only one process when multiple processes are listening socket
ambrus at math.bme.hu
Wed Jul 17 00:47:44 CEST 2013
On 7/16/13, trafdev <trafdev at mail.ru> wrote:
> Currently I have a solution where N similar processes are launched from
> command line,
> listening on N different ports and there is a balancer which listens on
> one port and forwards requests
> to one of N ports in round-robin fashion.
With a separate balancer process, you could have every process have
the same listening socket file descriptor, have the balancer process
wait for it to be readable, have it send some sort of message to
notify one of the other processes (this message could be a write to an
auxiliary unix domain socketpair, a posix message queue message, a
signal, or anything else), and have that other process accept the
connection from the listener socket. This doesn't sound too
complicated to me, though it gets more complicated if you also want
the balancer to choose a child that is the least busy currently.
You could develop a solution without an extra balancer process (or
thread), but I think it will likely be more complicated than a
solution with a dedicated balancer.
More information about the libev