The butterfly tutorial is a good example of using 0MQ's capabilities for load balancing using UPSTREAM / DOWNSTREAM sockets: you have one process S that binds on a socket and N identical processes Ri that connect to that socket; then the S process starts sending messages to the Ri processes, distributing them in a round-robin fashion among all Ri. You might call this "active-active load distribution" (because all the Ri processes are actively processing messages simultaneously).
I am wondering how one would build a variation of this design, where the S process sends ALL messages to a single Ri (R0, let's say). All the other Ri processes are there just in case R0 fails; when S detects that R0 is not receiving any messages, it switches to sending them to R1; and so on. You might call this "active-passive load distribution" (because only one Ri process is actively processing messages, while all the other processes are passively waiting to become the active one). One reason it might be advisable to process all messages with just one process is concurrency problems; if all Ri processes access the same database, running them simultaneosly might lead to contention, locking and even deadlocking. How would you approach this second scenario? One way I thought of was using a PUB socket in S and SUB sockets in each Ri, so that all of them receive all messages. The Ri processes also send a heart-beat message between themselves, and have a way of deciding which one is the current active process (such as voting). However, this is complex and forces each Ri to know about all other instances. Would it be possible to have a socket option (or type) that tells 0MQ not to round-robin among all Ri processes, but stick to one process only, and make the switch to the next one on a failure condition? Of course, you would have to define a policy for declaring such a failure. The failure condition also made me wonder: is there any way to control the queueing policy in 0MQ? Can I know how many messages are waiting in a queue to be delivered? Or how much "space" the queue has left? Can I control these values somehow? Your comments are most welcome. Thanks and best regards. -- Gonzalo Diethelm ----------------------------------------- Declaración de confidencialidad: Este Mensaje esta destinado para el uso de la o las personas o entidades a quien ha sido dirigido y puede contener información reservada y confidencial que no puede ser divulgada, difundida, ni aprovechada en forma alguna. El uso no autorizado de la información contenida en este correo podrá ser sancionado de conformidad con la ley chilena. Si usted ha recibido este correo electrónico por error, le pedimos eliminarlo junto con los archivos adjuntos y avisar inmediatamente al remitente, respondiendo este mensaje. "Before printing this e-mail think if is really necesary". Disclosure: This Message is to be used by the individual, individuals or entities that it is addressed to and may include private and confidential information that may not be disclosed, made public nor used in any way at all. Unauthorized use of the information in this electronic mail message may be subject to the penalties set forth by Chilean law. If you have received this electronic mail message in error, we ask you to destroy the message and its attached file(s) and to immediately notify the sender by answering this message. _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
