Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core Hangfire - Increase worker count

I have a .Net Core application with Hangfire implementation.

There is a recurring job per minute as below:-

RecurringJob.AddOrUpdate<IS2SScheduledJobs>(x => x.ProcessInput(), Cron.MinuteInterval(1));

var hangfireOptions = new BackgroundJobServerOptions
            {
                WorkerCount = 20,
            };
            _server = new BackgroundJobServer(hangfireOptions);

The ProcessInput() internally checks the BlockingCollection() of some Ids to process, it keeps on continuously processing.

There is a time when the first ten ProcessInput() jobs keeps on processing with 10 workers where as the other new ProcessInput() jobs gets enqueued.

For this purpose, I wanted to increase the workers count, say around 50, so that there would be 50 ProcessInput() jobs being processed parallely.

Please suggest. Thanks.

like image 960
Nitin Avatar asked Aug 22 '26 12:08

Nitin


1 Answers

In the .NET Core version you can set the worker count when adding the Hangfire Server:

services.AddHangfireServer(options => options.WorkerCount = 50);
like image 67
Tomáš Oplatek Avatar answered Aug 26 '26 01:08

Tomáš Oplatek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!