I was wondering if there is an option to set the limit so that hangfire doesn’t consuming 100% of CPU usage hang itself? I was expecting it will do that by default but seems like hangfire tries to use all available resource and I am noticing our web app is getting significantly slow. My understanding of background process is runs when the server has enough resource to run and executes without slowing down web app(main process) It’s possible I need to set the priority for each jobs so it doesn’t clog main process.
Does the hangfire smart enough not to consume all the resource and hang the hosting server?
Basically your assumption is off. Hangfire is just managing .net threads so if there is any resource throttling its done by the framework. From my perspective to set the priority on a thread you’ll will need to architect your own resource throttling or run the logic in a completely different process - for example on another box that is dedicated to do high cpu work. I do something similar by setting up custom queues and targeting those when i schedule/queue a job. Then it will execute on my worker server rather than web facing nodes.
this thread explains - One queue for the whole farm, and one queue by server