Hello,
We are doing a POC of Hangfire. I am using mostly the default settings as per the documentation to start hangfire server with SqlServer storage. I changed the worker count to 5 and using a connection factory instead of providing a connection string.
After starting the server I notice that there are lot of connections being requested almost every second. Once I change the QueuePollInterval from TimeSpan.Zero to TimeSpan.FromMinutes(1), then the connections are requested every minute.
From a previous dicussion on this forum, it is recommended to keep QueuePollInterval at zero. But based on what I’m seeing, this could put a lot of load on the Sql Server.
Is it ok to increase the QueuePollInterval as it fits us?
This is what I have in the startup code:
builder.Services.AddHangfire((sp, cfg) =>
{
var connFactory = sp.GetService<IDbConnectionFactory>();
cfg.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(() => connFactory?.GetNewConnection(),
new Hangfire.SqlServer.SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true,
});
});
builder.Services.AddHangfireServer(options =>
{
options.WorkerCount = 5;
options.StopTimeout = TimeSpan.FromSeconds(5);
});
Thanks in advance