HangfireIO / HangfireIO/Hangfire

100% CPU after completing a recurring job

Open
#1,972 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

Hi,

We use Hangfire 1.7.27 + Hagfire.Pro 2.3.0.0 + Hagfire.Pro.Redis 2.8.12.0

We are facing 100% CPU usage while hangfire is not processing any jobs after completing a recurring job
![01](https://user-images.githubusercontent.com/7472809/142371325-32b90b50-15ef-4afa-98cb-4e7a94b9b3bd.png)

How does this happen:
1. If restart the IIS then CPU load is 1-2%
2. If the only recurring job will be executed at least once then CPU load is 98-99% and does not decrease for a long time

I've collected trace at this moment on the server using dotTrace
![02](https://user-images.githubusercontent.com/7472809/142371614-e568103d-dae4-433e-add0-6d8b95e5a8b5.png)
RunWorkLoop in DedicatedThreadPoolPipeScheduler takes 50% time
Wait in CancellationTokenExtentions takes 20% time

This is RunWorkLoop code
https://github.com/mgravell/Pipelines.Sockets.Unofficial/blob/19b141f30fe2485dd79993be0ac87a9fc6b34b74/src/Pipelines.Sockets.Unofficial/DedicatedThreadPoolPipeScheduler.cs#L166

Contributor guide

Open the contributing guide

Research direction

Start with the linked DedicatedThreadPoolPipeScheduler.cs RunWorkLoop implementation and the dotTrace evidence described in the issue. Reproduce the recurring-job sequence after an IIS restart using Hangfire 1.7.27, Hangfire.Pro 2.3.0.0, and Hangfire.Pro.Redis 2.8.12.0. Done means the recurring job completes without leaving Hangfire at sustained 98–99% CPU.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.