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 <[email protected]> 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 > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
