Recurring job does not run sometimes

I have 3 websites configured in IIS which use the same application pool. Each use the same code base (by nature the database is different for each client) and execute a hangfire recurring job each day. Now for 2 of the websites I don’t have any problems but for one of the websites, the job does not run each day. Since the job starts immediately when a user access the website, this makes me think that the application pool is suspended and it is “awaken” when the user access the website.

I have already implemented the instructions so that the application is always running. As I mentioned it works fine for the other 2 and it is just for 1 website where it does not work always. Has anybody else encountered such things before? Or does Hangfire is showing signs of instability where the same code runs perfectly fine for 2 and intermittently for 1.


If they are true web applications in IIS (not virtual apps under the default) then you should not be having a problem.

I would start by adding some logging into the global.asax file for application state. See if something is, not crashing, but causing the app to sleep. I have seen this before (not related to HF) where the server itself did not have reosurces enough to run everything and would force-sleep inactive apps even when told not to in the config.

I might also add the same logging to the other apps, see if there is a conflict. Comb through your event viewer carefully, you might miss something obvious.

If you still can’t nail it down, and you have the resources, move the app to another IIS instance (VM’s are your friend! :slight_smile: ) and see how it runs.

The SQL connection pool might be oberloaded, so try some connection management.

Hope this helps.

Thanks for the suggestion. Somebody suggested that the application pool is running short on resources and recycling it every day might solve the problem. But it did not work. I believe that the server is strained and is forcing the apps to sleep like what you said. I haven’t tried the logging in the global file but what I am going ahead is pinging the application every hour so the application remains active. After observing it for a few days, I will update what the outcome is.

The solution to ping the application every hour has worked and all the 3 applications have been running perfectly for the last few days.