We are using Hangfire in production and turns out that we literally reach the database connections max limitation.
We have about 45 connections for just hangfire which seems a bit too much for just maintaining some long task running jobs.
I am wondering whether there is anything that can be done to change the number of connections, however, I can't find anything in the configuration providing such configuration.
You could try to reduce the number of workers as it is described here:
app.UseHangfire(config =>
{
//tell hangfire to only use 2 workers
config.UseServer(2);
});
Hangfire default takes 20 workers. You can override it on your startup. I used like below:
var options = new BackgroundJobServerOptions
{
WorkerCount=1 //Hangfire's default worker count is 20, which opens 20 connections simultaneously.
// For this we are overriding the default value.
};
app.UseHangfireServer(options);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With