草庐IT

mysql - 错误 : upstream prematurely closed connection while reading response header from upstream [uWSGI/Django/NGINX]

coder 2023-06-10 原文

我目前总是在我的用户正在执行的查询中得到 502...这通常返回 872 行并且需要 2.07 才能在 MySQL 中运行。然而,它返回了很多信息。 (每一行都包含很多东西)。有什么想法吗?

运行 Django(tastypie Rest API)、Nginx 和 uWSGI 堆栈。

使用 NGINX 配置服务器

# the upstream component nginx needs to connect to
upstream django {
    server unix:///srv/www/poka/app/poka/nginx/poka.sock; # for a file socket
}

# configuration of the server
server {
    # the port your site will be served on
    listen  443;


    # the domain name it will serve for
    server_name xxxx; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 750M;   # adjust to taste

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /srv/www/poka/app/poka/nginx/uwsgi_params; # the uwsgi_params file you installed
    }
}

UWSGI 配置

# process-related settings
# master
master          = true
# maximum number of worker processes
processes   = 2
# the socket (use the full path to be safe
socket          = /srv/www/poka/app/poka/nginx/poka.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true

pidfile = /tmp/project-master.pid # create a pidfile
harakiri = 120 # respawn processes taking more than 20 seconds
max-requests = 5000 # respawn processes after serving 5000 requests
daemonize = /var/log/uwsgi/poka.log # background the process & log
log-maxsize = 10000000
#http://uwsgi-docs.readthedocs.org/en/latest/Options.html#post-buffering
post-buffering=1
logto = /var/log/uwsgi/poka.log # background the process & log

最佳答案

这不太可能是 nginx 配置问题。

几乎可以肯定的是,后端实际上正在崩溃(或只是终止连接),而不是给出格式错误的响应。即错误消息告诉您问题是什么,但您正在寻找错误的地方来解决它。

你没有提供足够的信息来让我们找出确切的问题是什么,但如果我不得不猜测:

which usually returns 872 rows and takes 2.07 to run in MySQL. It is however returning a LOT of information.

它要么在某处超时,要么内存不足。

关于mysql - 错误 : upstream prematurely closed connection while reading response header from upstream [uWSGI/Django/NGINX],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22107726/

有关mysql - 错误 : upstream prematurely closed connection while reading response header from upstream [uWSGI/Django/NGINX]的更多相关文章

随机推荐