[zeromq-dev] Should 0MQ be used and what socket types to use?

Charles Remes lists at chuckremes.com
Sat Jan 26 11:08:16 CET 2013

On Jan 25, 2013, at 11:58 PM, Niels Berglund <niels.it.berglund at gmail.com> wrote:

> Hi all!
> I am working for a company whose business is similar to online financial trading, where the similarities are the requirement for low latency and high throughput. 
> The systems are situated in data centers across the world, and clients connect over the internet to an individual system. A system consists of a software router which routes requests from clients to back-end services, and responses to the clients from the services. The services may also send unsolicited messages to the clients.
> There are a limited number of back-end services, but there could theoretically be an infinite number of concurrent users.  Obviously there are limitations how many clients can connect to one specific software router, but there would then be multiple machines with software routers for the clients to connect to. 
> We are now looking at the future architecture, and part of that is communication mechanisms. The underlying OS for this is Windows and at the moment we are using Microsoft's socket library. Our socket code are functional, but not pretty and I have a feeling that if we were to change to something like 0MQ, etc., it would be beneficial for us.
> So my questions are:
> 1. Would an architecture like the above be feasible using 0MQ?
> 2. What 0MQ socket types would be best for an architecture like this? My thoughts are that clients would connect to the software router using a DEALER socket (seeing that we want full asynch, and that the client could send multiple requests without requiring a reply in between). The client-facing socket in the software router would be a ROUTER socket, but I am not sure if the client service facing socket in the software router should be a ROUTER or DEALER? As for the services, they would connect to the software router using a DEALER socket.

1. Yes, this architecture is very feasible. I have personally created a very similar architecture for my own trading applications.

2. I recommend using DEALER/ROUTER exclusively for any bidirectional communications. Those socket types can be viewed as the foundation for any protocol (that is, you can create any of the other patterns such as push/pull or pub/sub using just dealer/router). 

You will want heartbeating to detect dead (or slow) clients and services, so again dealer/router is the correct choice. I have found the other socket types to primarily be useful for intra-thread communication since they are (from the programmer perspective) uni-directional.

My system runs in production on the Windows platform. I have also deployed some services to linux but Windows is the primary target platform.

If you have other specific questions, feel free to ask.


More information about the zeromq-dev mailing list