views:

307

answers:

1

I've created a shiny new ASP.Net MVC site and I have offloaded the 'save as' type of functionality to a helper program that can be run in the background on the server so that the website doesn't need to take all that load.

I created it so that it's easy to run from the command line and right now I have it running from a windows scheduler. The problem is that that has a granularity of 1 minute, which means that some unlucky users of the website will click on the link and get a 59s wait + the time to actually process the report.

I'm also slightly worried about the start up cost of my program. I'm assuming that it would be cheaper to keep the program running constantly. I am worried about the program dying and not being respawned though. With the windows scheduler option at least I don't have to worry about my program bailing so much.

How have you dealt with that?

+2  A: 

I'd create a Windows Service and have that running instead of an exe via windows scheduler. You can then set it to auto-start. Then you can just have a timer within the service to poll for work every x seconds.

Another alternative is to use something like MSMQ. Your front end would just insert a message into the queue to represent the work to do, then have a .NET service listening to the queue (you can get it to process messages immediately they appear in the queue, or check the queue manually yourself every x seconds).

Either way, I think a Windows Service is the way to go.

AdaTheDev
+1; you can place your user request into that MSMQ queue, process it and to notify your user through email; that email could contain a link to your processes file, place into a webserver folder.
Rubens Farias