[zeromq-dev] Use of parameters in API for Multithreading

Martin Sustrik sustrik at fastmq.com
Tue Oct 20 12:09:20 CEST 2009


Hi,

> I am building an app with multiple receivers each in their own thread 
> and senders sending to multiple receivers. I see that the API for 
> creating queues and exchanges has parameters for threads but I cant find 
> an example that gives me a gd idea of how to make full use of the 
> parameters to create an optimal app for multiple thread system.
> 
> Also, do I have to create multiple io_thread_t and multiple api_thread_t 
> to achieve an optimal multithreaded system? and how does that related to 
> the number of threads I have to create in the dispatcher?
> 
> I need to built a high throughput system in a multicore environment. My 
> goal is to make full use of the threading to achieve highest throughput 
> possible.. Detail explanation on the parameters will be much 
> appreciated. Thx

There are two types of threads.

Application threads are those you create used to handle your business 
logic. For each application thread you have to create app_thread_t 
object that you can subsequently use for messaging.

I/O threads are worker threads that send/receive data to/from network. 
You don't create these threads manually, neither you have direct access 
to them. The only way you can use them is to assign them to 
exchanges/queues/bindings. So, for example, if you assign 3 I/O threads 
to a global exchange, network connections bound to that exchange will be 
load balanced among the three I/O threads.

Martin



More information about the zeromq-dev mailing list