I’m writing a .NET MVC application that needs two background processes to be running and I’m not sure if these processes should be threads within the web app, or if they should be separate windows services. I’d prefer them to be within the web app so that it’s easier to deploy, configure and manage.
The first process is a timed event that needs to check a datasource every 15 minutes to determine if certain products have been shipped. If any have been shipped, this process would take the info about the product and create a “job” record in a database table (a queue) so that it could be processed later.
The second process is another timed event that needs to check the database table (the queue) to see if there is any work to do. If there are unprocessed records, it would read them into a thread safe list, and then use several .NET Tasks to process them in parallel.
The reason I’m building this as a web app is that I’m going to give my customers the ability to view historical info on this process, the ability to manually submit jobs, and the ability to configure which products the application should “look” for.
Is there a good way to build all of this into the web app or should I be looking at splitting it up into multiple applications? The demand on the web views will be pretty low.
Phil Haack recently blogged about the challenges you will have to face if you ever decide to implement recurring background tasks directly in your web application in contrast to externalizing them in a separate service.