资源暂时不可用:mod_wsgi (pid=28433):无法连接到 WSGI 守护进程
Resource temporarily unavailable: mod_wsgi (pid=28433): Unable to connect to WSGI daemon process
首先:我正在使用 Apache/2.2.31 (Unix) 和带有 WSGI 的 Django 1.8 在 Web 服务器上工作。
一切都很好,直到我对 views.py 文件做了一些更改并触摸 wsgi.py 以使更改生效。紧接着,每次我尝试使用浏览器访问我域中的任何页面时,它 returns 显示以下消息:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to
maintenance downtime or capacity problems. Please try again later.
Additionally, a 503 Service Temporarily Unavailable error was
encountered while trying to use an ErrorDocument to handle the
request.
我的 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
还有这个未回答的问题:
但我不知道如何修复它。请帮帮我。
找不到答案后,我重启Apache解决了。
发件人: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.
我们发现调整 mod_wsgi listen-backlog
和增加 net.core.somaxconn
(至少在 Ubuntu 上)似乎可以消除 listener backlog limit was exceeded
问题。当然,这在很大程度上取决于流量和用户的水平。
首先:我正在使用 Apache/2.2.31 (Unix) 和带有 WSGI 的 Django 1.8 在 Web 服务器上工作。
一切都很好,直到我对 views.py 文件做了一些更改并触摸 wsgi.py 以使更改生效。紧接着,每次我尝试使用浏览器访问我域中的任何页面时,它 returns 显示以下消息:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Additionally, a 503 Service Temporarily Unavailable error was encountered while trying to use an ErrorDocument to handle the request.
我的 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
还有这个未回答的问题:
但我不知道如何修复它。请帮帮我。
找不到答案后,我重启Apache解决了。
发件人: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.
我们发现调整 mod_wsgi listen-backlog
和增加 net.core.somaxconn
(至少在 Ubuntu 上)似乎可以消除 listener backlog limit was exceeded
问题。当然,这在很大程度上取决于流量和用户的水平。