[zeromq-dev] Socket usage question

Martin Sustrik sustrik at 250bpm.com
Wed Aug 24 16:32:53 CEST 2011


On 08/24/2011 04:09 PM, Matt Haberman wrote:
> So I am assuming that in general, the best practice for communicating
> with 0MQ via a multi-threaded application is to maintain a fixed
> number of sockets (perhaps equal to the CPU core count) instead of
> creating a socket for each thread? I am trying to maximize
> throughput.

No. It's better to have a socket per thread. That way you can avoid 
locking, which becomes a bottleneck at high message rates.

However, optimal application should not use more threads than there are 
CPU cores on the box -- in which case both options are more or less 
equivalent.

Martin



More information about the zeromq-dev mailing list