Dashboard excessive database access


#1

Hello ,
i have a simple problem with the dashboard , how can prevent the dashboard from being so responsive .
it excessively checks in database for the count of the currently running jobs ,(recurrent jobs count , ,etc…)
to update the stats in the dashboard page , this makes a load on database i want to delay that check or trigger it with a simple refresh for the page.
thanks.

Here Is the query that retrieves the counts:-

set transaction isolation level read committed;
select count(Id) from [HangFire].Job with (nolock) where StateName = N’Enqueued’;
select count(Id) from [HangFire].Job with (nolock) where StateName = N’Failed’;
select count(Id) from [HangFire].Job with (nolock) where StateName = N’Processing’;
select count(Id) from [HangFire].Job with (nolock) where StateName = N’Scheduled’;
select count(Id) from [HangFire].Server with (nolock);
select sum(s.[Value]) from (
select sum([Value]) as [Value] from [HangFire].Counter with (readpast) where [Key] = N’stats:succeeded’
union all
select [Value] from [HangFire].AggregatedCounter with (nolock) where [Key] = N’stats:succeeded’
) as s;
select sum(s.[Value]) from (
select sum([Value]) as [Value] from [HangFire].Counter with (readpast) where [Key] = N’stats:deleted’
union all
select [Value] from [HangFire].AggregatedCounter with (nolock) where [Key] = N’stats:deleted’
) as s;

select count from [HangFire].[Set] with (nolock) where [Key] = N’recurring-jobs’;


#2

Ran into the same issue and set the StatsPollingInterval property in DashboardOptions to change the polling interval of the dashboard.
Something like this to make it only poll once per minute instead of the default every 2 seconds:

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
     StatsPollingInterval = 60000
});