Can Hangfire process background jobs immediately?

Tags: #<Tag:0x00007fb0053d4160>

I’m using a BackgroundServer with a Redis instance as the job queue. I’ve noticed that worker threads will not process anything until the number of background jobs on the queue has built up. I can’t tell whether it is waiting for the number of jobs to pass a threshold or using some sort of internal timer to trigger processing the jobs. I have two questions I was looking to have answered…

Is this normal behaviour?
Is there is some way to configure the server to process jobs as soon they appear on the queue?

Thanks,
C

No, that’s not a normal behavior. By default, Hangfire + Redis process background jobs immediately, unless queue is lengthy. Blocking calls or their emulation through the pub/sub are used right to reduce the processing latency to minimum. So here may be the following problems:

  1. Network problems that introduce the unexpected delays.
  2. Problems related to background jobs. What the dashboard says about duration and latency for your jobs? Can you give me the numbers?
  3. Problems with job filters. Are you using DisableConcurrentExecution or other filters, like custom ones?

The simplest way to learn what’s happening here is to obtain minidump, when the processing stuck, or to use the stdump utility I’ve recently wrote for such cases. You can use it against a live process to get the thread dumps without any interruption in the following way:

stdump-x64.exe {pid} > output.txt

Would you like to send me the stack traces of your process?