[英]Python WSGI deployment on Windows for CPU-bound application
What options do I have for the deployment of a CPU bound Python-WSGI application on Windows? 在Windows上部署CPU绑定的Python-WSGI应用程序时,我有哪些选择?
The application benefits greatly from multiple CPUs (image manipulation/encoding) but the GIL prevents it from using them. 该应用程序受益于多个CPU(图像处理/编码),但GIL阻止了它们使用它们。
My understanding is: 我的理解是:
mod_wsgi has no support for WSGIDaemonProcess on Windows and Apache itself only runs with one process mod_wsgi在Windows上不支持WSGIDaemonProcess,Apache本身仅运行一个进程
all fork based solutions (flup, spawning, gunicorn) only work on unix 所有基于fork的解决方案(flup,spawning,gunicorn)仅适用于UNIX
Are there any other deployment options I'm missing? 我还有其他部署选项吗?
PS: I asked that on serverfault but someone suggested to ask here. PS:我在serverfault上问过,但是有人建议在这里问。
I have successfully used isapi-wsgi to deploy WSGI web apps on Windows IIS (I assume that since you're deploying on Windows, IIS is an option). 我已成功使用isapi-wsgi在Windows IIS上部署WSGI Web应用程序(我假设由于您是在Windows上进行部署,因此IIS是一个选择)。
Create an IIS Application Pool to host your application in and configure it as a Web Garden (Properties | Performance | Maximum number of worker processes). 创建一个IIS应用程序池来承载您的应用程序并将其配置为Web Garden(“属性” |“性能” |“最大工作进程”数)。
Disclaimer: I have never used this feature myself (I have always used the default App Pool configuration, where Max. number of worker processes is 1). 免责声明:我从未亲自使用过此功能(我一直使用默认的App Pool配置,其中工作进程的最大数量为1)。 But it is my understanding that this will spin up more processes to handle requests. 但是据我了解,这将启动更多进程来处理请求。
It would be a bit of a mess, but you could use the subprocess module to fire off worker processes yourself. 可能会有些混乱,但是您可以使用子流程模块自行触发工作进程。 I'm pretty sure that Popen.wait() and/or Popen.communicate() ought to release the GIL. 我很确定Popen.wait()和/或Popen.communicate()应该释放GIL。 You've still got the process creation overhead though, so you might not gain a lot/anything over standard CGI. 但是,您仍然需要创建流程,因此您可能无法从标准CGI中获得很多收益。
Another option is to have separate server/worker processes running the whole time and use some form of IPC, although this isn't going to be an easy option. 另一个选择是让单独的服务器/工作进程始终运行并使用某种形式的IPC,尽管这并不是一个简单的选择。 Have a look at the multiprocessing module, and potentially also Pyro. 看一下多处理模块,可能还有Pyro。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.