Should I combine my DataReaders under one Subscriber, or use separate Subscribers?

Note: Applies to RTI Connext 4.x and above.

What is the trade-off between having one Subscriber with multiple DataReaders, versus multiple Subscribers that each have one DataReader?

Typically, an application will have one Subscriber with multiple DataReaders.

If the DataReaders are set up to use the same receive port (the default case), the difference in performance between creating them on the same or different Subscribers is small.

Here are some trade-offs to be aware of.

Concurrency and Memory Usage

DataReaders that belong to the same Subscriber cannot be used concurrently.

There is a trade-off between concurrency and memory usage: using more Subscribers will give you more concurrency, but at the same time will use up more memory.

If one DataReader is in the middle of processing received data or your application is making a call on the DataReader, all other DataReaders belonging to that same Subscriber will be blocked until the in-use DataReader is finished.

So, if you want to make sure that the DataReaders can only be accessed one at a time, put them under the same Subscriber. If you want the ability to access the DataReaders concurrently, use different Subscribers. 

However, note that RTI Connext only creates a single thread to listen to received data per receive port. So even if the DataReaders belong to different Subscribers, if they are using the same receive port, only one of them can be receiving data at a time. (A Datareader's receive port is set in the TransportUnicast QoS Policy.)

Management 

Another thing to keep in mind is that by using a single Subscriber, you can query for all the DataReaders that belong to it. It makes it easier to manage your DataReaders.

Here are two situations in which you might want to use multiple Subscribers to create separate groups of DataReaders

  1. To use the Partition QoS policy to create a logical partition among Topics.
  2. To use distinct sets of listeners/callback methods. RTI Connext looks for listeners in the following order: DataReader, Subscriber, then DomainParticipant. Only the first one found will be called. DataReaders that belong to the same Subscriber can share the same callback methods.

 

Other  similar  links:

1. http://community.rti.com/best-practices/create-few-publishers-and-subscribers-possible