资源暂时不可用:mod_wsgi (pid=28433):无法连接到WSGI守护进程。

4
首先:我正在使用Apache/2.2.31 (Unix)和Django 1.8与WSGI构建web服务器。
一切都很好,直到我更改了views.py文件并触及wsgi.py以使更改生效。之后,每次我尝试通过浏览器访问域中的任何页面时,会返回以下消息:
“服务暂时不可用”
由于维护停机或容量问题,服务器暂时无法为您提供服务。请稍后再试。
此外,在尝试使用错误文件处理请求时遇到503 Service Temporarily Unavailable错误。
我的Apache error_log具有以下条目:
[Mon Dec 28 23:06:02 2015] [error] [client xx.xx.xx.xx] (11)Resource temporarily unavailable: mod_wsgi (pid=24172): Unable to connect to WSGI daemon process 'name_of_my_project' on '/route/to/apache/log/wsgi.1922.18.1.sock' after multiple attempts as listener backlog limit was exceeded., referer: http://myproject.com/
[Mon Dec 28 23:06:17 2015] [error] [client xx.xx.xx.xx] (11)Resource temporarily unavailable: mod_wsgi (pid=24172): Unable to connect to WSGI daemon process 'name_of_my_project' on '/route/to/apache/log/wsgi.1922.18.1.sock' after multiple attempts as listener backlog limit was exceeded., referer: http://myproject.com/
[Mon Dec 28 23:16:02 2015] [error] [client xx.xx.xx.xx] (11)Resource temporarily unavailable: mod_wsgi (pid=28572): Unable to connect to WSGI daemon process 'name_of_my_project' on '/route/to/apache/log/wsgi.1922.18.1.sock' after multiple attempts as listener backlog limit was exceeded.
[Mon Dec 28 23:16:17 2015] [error] [client xx.xx.xx.xx] (11)Resource temporarily unavailable: mod_wsgi (pid=28572): Unable to connect to WSGI daemon process 'name_of_my_project' on '/route/to/apache/log/wsgi.1922.18.1.sock' after multiple attempts as listener backlog limit was exceeded.

我整天在寻找解决方案,最后找到了这个:https://groups.google.com/forum/#!topic/modwsgi/H7qPoqYNJdI和无人回答的问题:https://stackoverflow.com/questions/33549891/mod-wsgi-returning-503-service-unavailable但我不知道该如何解决。请帮忙。

有趣。我总是重新启动Apache来应用更改,从未遇到过问题。发布您的Apache /虚拟主机wsgi设置可能会有所帮助。 - Nostalg.io
3个回答

0

在找不到答案后,我通过重新启动Apache解决了这个问题。


1
这就是方法。 - otaku

0
我们发现调整 mod_wsgi listen-backlog 并增加 net.core.somaxconn(至少在 Ubuntu 上)似乎可以消除 listener backlog limit was exceeded 问题。当然,这高度取决于流量和用户的水平。

0

来源:http://engineering.hackerearth.com/2013/11/21/scaling-python-django-application-apache-mod_wsgi/

调整 mpm-worker 配置

<IfModule mpm_worker_module>
    StartServers         2
    MinSpareThreads      10
    MaxSpareThreads      25
    ThreadLimit          25
    ThreadsPerChild      25
    MaxClients           75
    MaxRequestsPerChild   0
</IfModule>

这个配置强制执行以下规则:

Initial number of server processes started is two.
Maximum number of clients is restricted to 75.
Each process has 25 threads.
Maximum number of processes that could be created is 75/25 = 3.
Our process size is ~220 MB (very very fat, I know!), so that means we only need ~660 MB in the worst case.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接