[英]How can send all request from client to single process in server.?
I am developing the web site, It consists of device name list and related Build Button. 我正在开发网站,它由设备名称列表和相关的“生成”按钮组成。 When one click the Build button the one process will run in server.
当单击“生成”按钮时,一个进程将在服务器中运行。 When more than ten user click the Build button more processes will create at that server will hang.
当十多个用户单击“生成”按钮时,将在该服务器上挂起的更多进程将挂起。 How can send all request from client to single process in server.
如何将所有请求从客户端发送到服务器中的单个进程。
You could set up a WCF Windows service that internally has some kind of count of currently running processes and makes sure that there are never more than X threads each running one process. 您可以设置一个WCF Windows服务,该服务在内部对当前正在运行的进程进行某种计数,并确保每个运行一个进程的X线程数量不得超过X个。 If you want exactly one, rather than just a limited amount, you don't even need to worry about the threads and can just halt other requests while it's processing one.
如果您只需要一个请求,而不是有限的请求,您甚至不必担心线程,可以在处理一个请求时暂停其他请求。
It might make it more difficult to give feedback to the users though if that's needed, since if one or more processes are queued, you can't immediately tell the user that the build has begun etc. 如果需要的话,向用户提供反馈可能会更加困难,因为如果一个或多个进程排队,则您无法立即告诉用户构建已经开始,等等。
It sounds like you are spawning a process thread to do the build on the sever (I don't recommend this, as spawning threads in a ASP.Net application can be tricky ). 听起来您好像正在生成一个进程线程以在服务器上进行构建(我不建议这样做,因为在ASP.Net应用程序中生成线程可能很棘手 )。 The easiest way to get around each request spawning a new thread would be to separate out your build process from the Asp.net web application.
解决每个请求产生新线程的最简单方法是将构建过程与Asp.net Web应用程序分开。 So:
所以:
Your other option is to log the requests to a queue, and have a process (windows service maybe) monitor the queue, and process it one at a time. 您的另一种选择是将请求记录到队列中,并有一个进程(可能是Windows服务)监视队列,并一次处理一个。 The drawback to this is that you won't get immediate results for the user.
这样做的缺点是您不会立即为用户得到结果。 You'll need some way of notifying them when the process has finished, but you'll most likely have to do the same thing with the above solution too.
您将需要某种方法在流程结束时通知他们,但是您很可能也必须对上述解决方案做同样的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.