This question was handled theoretically on stackoverflow here. I have the same issue of processing a large text file (2MB) where my processing worker gets stuck in my asp.net solutions.
My question, how do you avoid that hangfire gets suspended by IIS on my development and production server?
This may sound like an oversimplification - but consider running your Hangfire processes as a Windows Service. That way - you can separate your tiers - and preserve IIS processing power for serving pages.
I come from the linux side, so running things in the background is something that I’m familiar with, but not in windows. So you are basically saying that I should outsource my hangfire mechanism into another project like a console project and then auto start it?
Yes.
That way, your console and worker process(es) are not tied together.
For example, in my environment, I have the following:
- Dashboard running on an Azure Web App
- Default Queue Processor running on Local VM
- Default Queue Processor running on Local VM
- Default Queue Processor running on Local VM
- Dedicated Queue Processor running on Local VM
- Cache Queue processor running on remote VM
IIS is finickey - it recycles the app pool seemingly at random. I started out processing my HF jobs on IIS - but found it too unreliable. So, I moved to a console app (actually series of instances of a console app) - for multiple reasons.
- I can spin up as many as I need quickly.
- If one dies, another will pick up the slack.
- Heavy loads won’t impact IIS performance of my main app.
- Higher throughput (theoretically - I haven’t tested this) - because you’re not dealing with the overhead of IIS
That’s what’s in my head right now. I’m no expert - but feel free to ask follow-up questions!
I’m no expert either but I was able to spin up several hf processes. But could you upload an example console application to github?
And if I put hf in a seperate console application, do I have access to the hf dashboard. I was googling around, apparently you need to do an owin web application, but I only saw some snippet code.