High CPU and memory usage on production server


I am using Hangfire to process (upload excel file data to database table) large excel files in background from web application. This excel files can have upto 35k records in it and different users from different part of world can upload this files which goes for processing using hangfire in background. So multiple excel files(having 35k records in it) at the same time can be there for processing.

The problem I am facing is, my production server’s CPU usage and Memory goes to alomst 99% (which hangs my all production sites and makes my life hell !!!) when excel files are being processed using hangfire. so whenever multiple users uploads excels for processing on my production server, it just gets crazy and stucks all the processes and restart happens !!!

Please provide me more details on how hangfire works and please do the needful asap.

Hi Vibhuti!
it does not seem to be a problem on hangfire…let me know, what exactly you do when excel is uploaded?

Thank you for reply.Further to investigation on production server, I have observed that in Hangfire.Server table , there are multiple entries and it keeps adding/deleting entries frequently. Importantly, in Hangfire.server table, Data column uses the same process Id/PID as of my web application.(observed in task manager) So I can say that my application’s process id is keep changing frequently !!

As per my understanding, Process ID should not change frequently for web application running under application pool. It gets changed only when application pool recycles as new process creation happens on recycle.

Is hangfire creates new server /process on each new job creation?( and new entry in Hangfire.Server table) Or it just creates it when hangfire server started or app pool recycles?

Is my application’s pool/Production server is having some problem due to which process is being created frequently and its impacting hangfire?

Also, Is there any direct relationship of worker count and server process creation? I have restricted my workcount to 2 due to some severe memory problems on my production server. I have increased polling to 30 minutes as well.

I have attached necessary snapshot to have better idea. Please have a look and suggest asap.


:smiley: i’m here to try help…
No man, the little i know…the hangfire will create one server when is started…and dispose the server when is stopped…by the way, if your application is recycled and you forget to execute the Stop() method, other server will be created and the old server will be stopped by timeout.
Where you initialize and configure hangfire?

Thanks for your quick reply.
I am configuring hangfire in “owin based startup” file which resides at root level in my web application.
I have attached snapshot of configuration.

Please do the needful.