How to process more messages in the queue


Our team is using nservicebus and need some help.

We have nservicebus over MSMQ. Producer / publisher puts lot of messages in the queue and we have handler but sometimes there are too many messages in the queue. So what options does nservicebus provide to speed up processing message in the queue, does nservicebus call multiple instances of the handler, can we replicate handlers.


Hi Kedar,

You can look into scaling out your processing endpoints and use sender-side distribution.
Here’s a documentation link that would give you and idea how it works.

Hi Kedar,

It is important to understand what your current bottleneck is. Just increasing the concurrency and/or scaling out is not necessarily the fix for your throughput issue. For example, if your database is the bottleneck, scaling out your endpoints or increasing the maximum concurrency will only make things worse.

Which version of NServiceBus are you using? Prior to V6 NServiceBus would by default process message sequentially. Version 6 onwards the default concurrency is equal to the amount of cores on the machine.

If your endpoint still has enough CPU, RAM and network resources you might want to increase the maximum allowed concurrency. I personally experienced good results between 2 and 4 times the amount of cores on a machine but it depends on many factors.

If increasing the concurrency doesn’t help you could spread out our endpoints over multiple machines. For example, you currently have 10 endpoints on a single machine, consider using a single machine per endpoint. Once your endpoint runs on a single machine and still isn’t providing enough throughput I would consider scaling out this endpoint as suggested by @SeanFeldman


1 Like

Hi @Kedarnag,

Please also specify the version of NServiceBus you are using and which transport. Besides the questions @ramonsmits posted, how many is “too many messages”? Please provide some information about the average throughput you have.