This program is used for taking data that has been imported and exported it line by line to normalized tables. It can take hours sometimes.
此程序用于将已导入的数据逐行导出到规范化表。有时需要几个小时。
How it works is
它是如何工作的是
- Uses presses button to begin processing
- 使用按下按钮开始处理
- A call is made from jquery to a method on the MVC controller.
- 从jquery调用MVC控制器上的方法。
- That controller calls a DLL which then begins the long processing
- 该控制器调用一个DLL,该DLL开始长时间的处理
Only one person uses this program at a time.
每次只有一个人使用这个程序。
We are worried about it tying up a ASP.NET IIS thread. Would this be more efficient if instead of the web site running the code we could make a scheduled task that runs a EXE every 30 minutes to check and process the code..
我们担心它会捆绑ASP。净IIS线程。如果我们不用运行代码的web站点,而是每30分钟运行一次EXE来检查和处理代码,这会更有效吗?
EDIT 1: After talking to a coworker the work around we will do for now is simply remove the button from the web site that processes and instead refactor that processing into a scheduled task that runs every 5 minutes ... if there are any comments about this let me know.
编辑1:在与同事交谈之后,我们现在要做的就是从处理的网站上删除按钮,将处理过程重构为每5分钟运行一次的预定任务……如果对此有任何意见,请告诉我。
The question is really about the differences between the web site running code vs. a completely separate EXE...IIS threads vs. processes... Does it help any ?
真正的问题是网站运行代码和完全独立的EXE之间的区别。IIS线程与进程……有帮助吗?
2 个解决方案
#1
2
If the processing takes hours, it should definitely be in a separate process, not just a separate thread. You complicate thread locking and management, garbage collection and other things by dropping this into a separate process. For example, if your web server needs to be rebooted, your separate process can continue running without being affected. With a little work, you could even spin up this process on a separate server if you want (of course you would need to change the process start mechanism to do this)
如果处理需要几个小时,那么它肯定应该是在一个单独的进程中,而不仅仅是一个单独的线程。通过将线程锁定和管理、垃圾收集和其他事情放入一个单独的进程中,您将使线程锁定和管理、垃圾收集和其他事情复杂化。例如,如果您的web服务器需要重新启动,那么您的独立进程可以继续运行而不受影响。只要做一点工作,您甚至可以在单独的服务器上将该进程展开(当然,您需要更改进程启动机制)
#2
1
When the task can run for hours having it block an ASP.Net thread is definitely the wrong thing to do. A web call should complete in a reasonable amount of time (seconds ideally, minutes at worst). Tasks which take considerably longer than that can be initiated from a web request but definitely shouldn't block the entire execution.
当任务可以运行数小时时,让它阻塞ASP。Net线程绝对是错误的。web调用应该在合理的时间内完成(最好是几秒,最糟糕的是几分钟)。需要花费相当长时间的任务可以从web请求启动,但绝对不应该阻塞整个执行。
I think there are a couple of possible paths forward
我认为有两种可能的出路
- If this is a task that does need to be executed on a semi-regular basis then factor it into an EXE and schedule the task to run at the correct interval
- 如果这个任务确实需要在半规则的基础上执行,那么将它分解为EXE,并安排任务在正确的间隔运行
- If this task should run on demand then factor it out into an EXE and have the web request kick off the EXE but not wait for its completion
- 如果该任务应该按需运行,那么将其分解为EXE,让web请求启动EXE,而不是等待其完成
- Another possibility is to factor it out into a long running server process. Then use remoting or WCF to communicate between asp.net and the process
- 另一种可能是将其分解为一个长期运行的服务器进程。然后使用remoting或WCF在asp.net和进程之间进行通信
#1
2
If the processing takes hours, it should definitely be in a separate process, not just a separate thread. You complicate thread locking and management, garbage collection and other things by dropping this into a separate process. For example, if your web server needs to be rebooted, your separate process can continue running without being affected. With a little work, you could even spin up this process on a separate server if you want (of course you would need to change the process start mechanism to do this)
如果处理需要几个小时,那么它肯定应该是在一个单独的进程中,而不仅仅是一个单独的线程。通过将线程锁定和管理、垃圾收集和其他事情放入一个单独的进程中,您将使线程锁定和管理、垃圾收集和其他事情复杂化。例如,如果您的web服务器需要重新启动,那么您的独立进程可以继续运行而不受影响。只要做一点工作,您甚至可以在单独的服务器上将该进程展开(当然,您需要更改进程启动机制)
#2
1
When the task can run for hours having it block an ASP.Net thread is definitely the wrong thing to do. A web call should complete in a reasonable amount of time (seconds ideally, minutes at worst). Tasks which take considerably longer than that can be initiated from a web request but definitely shouldn't block the entire execution.
当任务可以运行数小时时,让它阻塞ASP。Net线程绝对是错误的。web调用应该在合理的时间内完成(最好是几秒,最糟糕的是几分钟)。需要花费相当长时间的任务可以从web请求启动,但绝对不应该阻塞整个执行。
I think there are a couple of possible paths forward
我认为有两种可能的出路
- If this is a task that does need to be executed on a semi-regular basis then factor it into an EXE and schedule the task to run at the correct interval
- 如果这个任务确实需要在半规则的基础上执行,那么将它分解为EXE,并安排任务在正确的间隔运行
- If this task should run on demand then factor it out into an EXE and have the web request kick off the EXE but not wait for its completion
- 如果该任务应该按需运行,那么将其分解为EXE,让web请求启动EXE,而不是等待其完成
- Another possibility is to factor it out into a long running server process. Then use remoting or WCF to communicate between asp.net and the process
- 另一种可能是将其分解为一个长期运行的服务器进程。然后使用remoting或WCF在asp.net和进程之间进行通信