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

Pieter Hintjens ph at imatix.com
Mon Jul 8 10:53:56 CEST 2013


Hi Colin,

Creating sockets costs little and your approach sounds fine. If you
have any doubt, just try a test where you create a lot of sockets, and
measure what it costs in terms of CPU and memory.

-Pieter

On Sun, Jul 7, 2013 at 8:09 PM, Colin Ingarfield <colini98 at gmail.com> wrote:
> Hello,
>
> 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,
> Colin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list