What to prefer a windows service or process integrated with asp.net website to encode files?
I have to create a website where users will upload the files and after that those files will be encoded with the help of an encoder exe. I want to know if I should integrate the file encoding log开发者_开发百科ic with the file uploading logic or create a different windows service which will be hitting the database in a definite time interval and will encode the non encoded files?
Thanks in advance.
Since encoding files is a "long-running task" it shouldn't per part of ASP.NET itself... I would strongly recommend use of Windows Service... esp. if you already have a DB this can easily be scaled if needed...
EDIT - as per comment:
long-running thread in ASP.NET means among other things:
- you use up IIS resources (threads from the IIS thread pool)
- it can be recycled whenever IIS feels like it (IIS does recycle the app pool in some configurable interval but also when memory or CPU gets scarce)
A Windows Service has the nice feature of running without having a user logged in interactively and thus you could scale such a solution by adding more systems and installing the Windows Service... for an alternative approach (Task scheduler based) see answer from David Piras
I agree with Yahia but would also tell about another way to do it out of the ASP.NET process and without overhead of creating and installing and maintaining a Windows Service.
You can create a UI less console application that gets called by windows task scheduler at every some minutes or once a day or as you wish to configure it: it can accept command line parameters and connect to the database and do the required job. all like you wish but without overhead of a service always running. in the end hou get same results. :-)
it really depends if you will reuse your Agent-like service for other things or not. relying on windows task scheduler allows you to do not implement time based triggering as Windows will do it, reliably, for you.
加载中,请稍侯......
精彩评论