【问题标题】:Resource temporarily unavailable: mod_wsgi (pid=28433): Unable to connect to WSGI daemon process资源暂时不可用:mod_wsgi (pid=28433):无法连接到 WSGI 守护进程
【发布时间】:2016-04-02 22:27:07
【问题描述】:

首先:我正在使用 Apache/2.2.31 (Unix) 和带有 WSGI 的 Django 1.8 开发 Web 服务器。

一切都很好,直到我对 views.py 文件进行了一些更改并触摸了 wsgi.py 以使更改生效。之后,每次我尝试使用浏览器访问我域上的任何页面时,它都会返回以下消息:

服务暂时不可用

由于以下原因,服务器暂时无法处理您的请求 维护停机时间或容量问题。请稍后再试。

此外,503 Service Temporarily Unavailable 错误是 尝试使用 ErrorDocument 处理 请求。

我的 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/virtualhost wsgi 设置可能会有所帮助。

标签: python django apache mod-wsgi http-status-code-503


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    发件人: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.
    

    【讨论】:

      【解决方案3】:

      在没有找到答案后,我通过重启 Apache 解决了。

      【讨论】:

      • 就是这样。
      猜你喜欢
      • 2017-01-13
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-19
      相关资源
      最近更新 更多