I am working on an asp.net mvc-5 web application deployed under windows 2012 and iis-8. My asp.net mvc has many CRUD operations that are implemented as action methods inside my asp.net mvc. But my asp.net mvc web application will carry out the planned lengthy network scanning process, network scanning will basically do the following steps: -
- Get a list of our servers and vms from our database.
- Get the username and password for scanning for each server and vm from a third-party tool using the Rest API.
- Call several powershell scripts to get the servers and vms information, such as network information, memory, name, etc.
- Update our ERP system with verification information using the Rest API.
Now I have completed a pilot project using the following approach: -
- I am defining the Model method inside my asp.net mvc to complete the above 4 steps.
- Then I install the hangfire tool, which will invoke the scan method on the predefined scheduler.
- I also create a View inside my asp.net mvc, which allows users to set hangfire schedule parameters (for this, IIS reset must be done on the host server for hangfire to get the new settings).
Now I run a test scan for 150 servers, which took about 40 minutes, and it worked fine. The only thing I noticed is that if I set up a schedule for working after hours (if no actions are performed in IIS), then hangfire will not be able to call the task, and as soon as the first request is completed, the missed tasks will start. I overcome this limitation by defining a Windows task that calls IIS every 15 minutes to maintain the application pool in real time, and it worked well ...
Now the other approach that I am reading makes mine higher, as follows: -
- Instead of defining a model method inside asp.net mvc to perform a scan, I can create a separate console application for scanning.
- Then, inside my asp.net mvc, a view is created that allows users to create and schedule a task inside the Windows Task Scheduler. I can do this by integrating with the Windows Task Scheduler API.
- If this Windows task calls a console application.
Now I'm not sure which approach is better and why? now, generally speaking, lengthy work / background jobs should not run under iis. But at the same time, defining these lengthy processes as a console application and invoking these applications inside the Windows Task Scheduler will create additional dependencies on my web application. And it will add extra effort when moving the application from the transition server to another (for example, from a test to live). In addition, I read that tools like hangfire, quartz, and others are designed to run long tasks inside IIS, and they eliminate the need to create console applications and schedule these console applications using the task scheduler. So can anyone advise this?
john g
source share