NServiceBus uses defaults that ensure good performance in most common cases. While this is usually the preferred mode of operation there are situations where tuning needs to be applied.
max(Number of logical processors,2).
Define a maximum concurrency setting that will make sure that no more messages than the specified value is ever being processed at the same time. Set this value to
1 to process messages sequentially. If not specified the transport will choose an optimal value.
Examples where concurrency tuning is relevant are
- Non thread safe code that needs to run sequentially
- Databases that might deadlock when getting too many concurrent requests
NOTE: The endpoint needs to be restarted for concurrency changes to take effect.
Throughput throttling options have been deprecated. To enable throttling on Version 6 and higher, a custom behavior should be used. The throttling sample demonstrates how such a behavior can be implemented.
The default concurrency settings of an endpoint can be changed via code:
Depending on the chosen transport, additional queues (satellite queues) may be used to handle deferred messages like delayed retries or timeouts. Satellite queues use the default concurrency configuration. This concurrency setting can be configured using:
var timeoutManager = endpointConfiguration.TimeoutManager(); timeoutManager.LimitMessageProcessingConcurrencyTo(4);