Search code examples
rebusrebus-azureservicebus

Workers and parallelism with Rebus


I have questions on threading below:

1 What are the default value for both methods below:

2 SetNumberOfWorkers: are the workers dedicated threads or via Thread pools?

Configure.With(...)
    .(...)
    .Options(o => {
        o.SetNumberOfWorkers(1);
        o.SetMaxParallelism(10);
    })
    .(...)

https://github.com/rebus-org/Rebus/wiki/Workers-and-parallelism

//
// Summary:
//     Configures the total degree of parallelism allowed. This will be the maximum
//     number of parallel potentially asynchrounous operations that can be active, regardless
//     of the number of workers
public void SetMaxParallelism(int maxParallelism);
//
// Summary:
//     Configures the number of workers to start competing over the input queue
public void SetNumberOfWorkers(int numberOfWorkers);

Solution

  • Rebus defaults to 1 single worker thread and a max parallelism of 5 – this is easy on the CPU, but it can still perform lots of work if work is asynchronous.

    The worker threads are dedicated threads used to overcome limitations for transports with synchronous APIs.

    The wiki page has been updated accordingly :)