Nginx   发布时间:2022-05-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux – gunicorn django nginx unix:// socket失败(11:资源暂时不可用)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

在配置有django,gunicorn,supervisor和Nginx的这些服务器上运行非常高的流量.但很多时候我倾向于看到502错误.所以我检查了Nginx日志以查看错误,这是记录的内容:

任何人都可以帮助调试可能导致这种情况发生的原因吗

这是我们的Nginx配置:

sendfile on;
tcp_nopush on;
tcp_nodelay off;

listen 80 default_server;
server_name imp.ourapp.com;
access_log /mnt/ebs/nginx-log/ourapp-access.log;
error_log /mnt/ebs/nginx-log/ourapp-error.log;

charset utf-8;
keepalive_timeout 60;
client_max_body_size 8m;

gzip_types text/plain text/xml text/css application/javascript application/x-javascript application/json;

LOCATIOn / {
    proxy_pass http://unix:/tmp/gunicorn-ourapp.socket;
    proxy_pass_request_headers on;
    proxy_read_timeout 600s;
    proxy_connect_timeout 600s;
    proxy_redirect http://localhost/ http://imp.ourapp.com/;
    #proxy_set_header Host              $host;
    #proxy_set_header X-Real-IP         $remote_addr;
    #proxy_set_header X-ForWARDed-For   $proxy_add_x_forWARDed_for;
    #proxy_set_header X-ForWARDed-Proto $my_scheR_181_11845@e;
    #proxy_set_header X-ForWARDed-Ssl   $my_ssl;
}

我们已将Django配置为在Gunicorn中作为通用Wsgi应用程序运行. Supervisord用于发射炮兵工人:

这就是gunicorn.conf.py的样子:

import multiprocessing

bind = 'unix:/tmp/gunicorn-ourapp.socket'
workers = multiprocessing.cpu_count() * 3 + 1
timeout = 600
graceful_timeout = 40

有谁知道我可以从哪里开始挖掘,看看可能导致问题的原因是什么?

这是我的ulimit -a输出在服务器上的样子:

core file size          (blocks,-C) 0
data seg size           (kbytes,-d) unlimited
scheduling priority             (-E) 0
file size               (blocks,-f) unlimited
pending signals                 (-i) 59481
max locked memory       (kbytes,-l) 64
max memory size         (kbytes,-m) unlimited
open files                      (-n) 50000
pipe size            (512 bytes,-p) 8
POSIX message queues     (bytes,-q) 819200
real-time priority              (-r) 0
stack size              (kbytes,-s) 8192
cpu time               (seconds,-t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes,-v) unlimited
file locks                      (-X) unlimited
最佳答案
我能够通过从128到20000编辑/ proc / sys / net / core / somaxconn来解决这个问题.这允许更大的流量突发.我可能没有必要将它设置得如此之高,但是这个应用程序可能会非常高.我也在使用gunicorn& Nginx的.

大佬总结

以上是大佬教程为你收集整理的linux – gunicorn django nginx unix:// socket失败(11:资源暂时不可用)全部内容,希望文章能够帮你解决linux – gunicorn django nginx unix:// socket失败(11:资源暂时不可用)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:gunicorn