I’m using Hangfire recurring background jobs overnight to update a variety of stuff in our databases. This is an ASP MVC Core 2.0 application running in a 4-core standard azure app service. These run just after midnight and at that point there are no users on the system.
I’ve noticed that the jobs runs considerably slower when triggered by hangfire as opposed to when they are run from within the application. On my local dev machine calling the function from a controller (outside of hangfire) takes about 30 seconds. The same function when triggered from within hangfire takes about 120 seconds, so about 1/4 the speed.
In Azure the difference is more drastic with the same function on the same DB taking up to 3-4 minutes when triggered from hangfire.
I’ve seen that there are options for settings server settings and parallel options for background jobs but I’m curious as to how to set it up so that the functions triggered by hangfire sees similar performance to the application.
The particular job I’m talking about has a lot of DB access with not a lot of processing. I’ve played around with breaking some of it into parallel tasks but I’d like to sort out how I can get similar performance to when I call the function from within the application.