Search code examples
zeromqnetmq

Understanding the MajorDomo Pattern from NetMQ ZeroMQ


I am trying to understand how to best implement the MDP example in c# to be used in a windows service in a multiple client - single server environment.

I have read the docs but I am still unclear on the following:

  • Should all Worker instances be created on startup and left to run?
  • Should the Workers all be different types of services or just different instances of the same service?
  • Can I have one windows service when contains the Broker and Workers or is it best to split them out into their own services?

The example code I am using is the MajorDomo Pattern taken from here https://github.com/NetMQ/Samples


Solution

    1. Yes, all workers in a MDP environment should be created independently of the requests, since the broker should not know how to create them
    2. Each worker handles a given "service" (contract). Obviously each contract should have at least one worker.
      • If you need parallelized handling of requests, and a given worker can only do one at a time, having extra workers for that service could make sense. Generally you would do this if multiple machines were involved however (horizontal scaling)
    3. You can have the broker and workers in the same process. HOWEVER, if you want to update only a worker, taking down the broker at the same time can be annoying for the clients. I would recommend letting the broker be its own process, with the workers in one or more other processes.