Nitin
Nitin

Reputation: 91

.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.

Upvotes: 3

Views: 10349

Answers (2)

Tom&#225;š Oplatek
Tom&#225;š Oplatek

Reputation: 360

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

services.AddHangfireServer(options => options.WorkerCount = 50);

Upvotes: 14

Victor.Uduak
Victor.Uduak

Reputation: 2824

you can try increasing the worker process using this method. You have to know the number of processors running on your servers. To get 100 workers, you can try

var options = new BackgroundJobServerOptions { WorkerCount = Environment.ProcessorCount * 25 };
app.UseHangfireServer(options);

Source

Upvotes: -1

Related Questions