[zeromq-dev] How expensive is an inproc connect?

Colin Ingarfield colini98 at gmail.com
Sun Jul 7 20:09:18 CEST 2013


I'm experimenting w/ jeromq in my servlet-based Java application.  One
of the problems I have run into is how to share a 0MQ socket with
multiple threads.  An "attached" thread w/ a PAIR socket is fine for 2
threads to communicate.  But client requests are processed by any
thread from my app server's thread pool.  (I saw this issue discussed
on the mailing list but did not see a good solution.)

My current approach is to bind a ROUTER socket to an inproc address w/
its own thread and poll loop.  When an app server-owned thread needs
to access this service it creates a new REQ socket and connects to the
router inproc address.  Then it can issue a request and the router
thread can do some work, whatever I need it to do.

I like this approach b/c it is clean, simple, and appears to work.  So
my question is: how expensive is it to create and connect these REQ
sockets?  How many req/sec before the overhead of the connection
becomes an issue?  Or are there better ways to solve this problem?

Thank you,

More information about the zeromq-dev mailing list