Closed keimpema closed 7 years ago
Thanks for signaling in such details. I believe that the problem is inside https://github.com/marcoCasamento/Hangfire.Redis.StackExchange/blob/master/Hangfire.Redis.StackExchange/RedisSubscription.cs#L28.
If you're in a hurry you could try to temporarily add:
cancellationToken.WaitHandle.WaitOne(TimeSpan.FromMinutes(3));
at the end of the Execute method, or you could alo try to rollback to 1.6.5.
Hope to carefully look at it this evening
@keimpema any news on this ? did you try something of the above ? I'd also like if @WebApelsin could give his insight on this
Yep, i think this could cause an idle load. The RedisSubscription
as IServerComponent
is wrapping in a loop inside the BackgroundProcessingServer
. The proposed solution from @marcoCasamento should help. The only thought, I'd better add it to the beginning of the Execute method.
On the other hand, we are using this version on the production server under high load and I can't see such issue. Probably, it depends on the used hardware.
I also tried nuget packages: 1.6.6.42 - same problem 1.6.5.24 - no problem at all
The 3 minute wait at the beginning of the Execute method works. I was wondering why 3 minutes though? Seems a bit long.
3 minutes it's totally arbitrary, just a wait long enough to don't cause problems. Every IServerComponent run the execute method in an infinite loop driven by hangfire engine. It's responsibility of the IServerComponent to pause in the exec in order to don't spike loads. RedisSubscription Implements IServerComponent to get notified of the server shutdown and free resources on Redis server Instance.
Putting it at the beginning of the method, as suggested by WebApelSin is the correct place, and no timeout (wait for ever) should be better than the 3 minutes. I'm trying this solution right now, to make sure that the Unsubscribe is called correctly (don't know how to unit test this!) then I'll push the fix.
Finally, I'd like to find a better way to handle the ISubscriber.Unsubscribe, (that use a thread for himself) but didn't find a better way to do it than this one, suggested by WebApelsin last month.
Thanks for the quick fix!
You welcome. I believe that the RedisStorage have to become IDisposable, but that's the topic for another issue, I'm going to close this one.
hello! I am currently experiencing this problem, how can I solve it in the end?
I am seeing 20% cpu usage when Hangfire server is idle when I use Hangfire.Redis.StackExchange. It stays at 0% when using SqlServerStorage. There are no jobs running. Maybe there is a tight loop somewhere?
I am using MSOpenTech Redis for Windows 3.0.504 and nuget packages:
Sql Server setup in startup.cs:
Redis setup:
VS performance monitor reports:
Redis![profilingreportredis](https://cloud.githubusercontent.com/assets/943820/20748853/2e799754-b6f0-11e6-9b5a-d13e9ad4ac79.png)
SqlServer![profilingreportsqlserver](https://cloud.githubusercontent.com/assets/943820/20748859/340cc4a2-b6f0-11e6-84dd-0c5979400d66.png)