服务端采用 Django + Nginx + Gunicorn 部署, 每次访问 /articles/{id} 这个接口时就报 500/502/504 错误。nginx 错误文件:
2018/01/15 16:49:44 [error] 1006#1006: *1274 upstream prematurely closed connection while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET /articles/6 HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/articles/6", host: "waterlaw.cn", referrer: "https://waterlaw.cn/"
2018/01/15 17:07:17 [error] 1006#1006: *1338 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/", host: "waterlaw.cn"
2018/01/15 17:10:47 [error] 22126#22126: *7 upstream prematurely closed connection while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/", host: "waterlaw.cn"
2018/01/15 17:14:26 [error] 22236#22236: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket/", host: "waterlaw.cn"
2018/01/15 17:16:03 [error] 22236#22236: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket/", host: "waterlaw.cn"
2018/01/15 17:43:44 [error] 22615#22615: *1 upstream prematurely closed connection while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET /articles/6 HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/articles/6", host: "waterlaw.cn", referrer: "https://waterlaw.cn/"
Gunicorn 控制台的错误日志:
[2018-01-15 17:51:19 +0800] [22183] [CRITICAL] WORKER TIMEOUT (pid:22730)
1
alect 2018-01-15 19:34:50 +08:00
upstream 设置的不对吧
|
2
Beebird 2018-01-15 19:47:30 +08:00
django 有日志输出吗? 有条件的话试试直接访问 django 的监听端口
|
3
beiposhiming 2018-01-15 20:20:55 +08:00 via iPad
想花式 500 ?
你得跟着 V2EX 多学学😂 |
4
flipped123 2018-01-16 09:14:27 +08:00
排查两方面,一个关闭防火墙试试,同时注意关闭 selinux 试试。
|
5
zpfhbyx 2018-01-16 09:37:07 +08:00
http://unix:/... 肯定连不上啊。。
|
6
xia0pia0 2018-01-16 10:05:37 +08:00
proxy_pass 配错了吧,upstream 那块的问题
|
7
waterlaw OP 不知道是不是文件句柄太多, 每次修改完都再次开启 gunicorn, 然后开了多个进程。 重启一下突然好了, 想到博客用了结巴分词, 然后缓存的时候占用了 1.5 秒。
|