我正在运行一个 nginx 服务器,它充当上游 unix 套接字的代理,如下所示:
upstream app_server {
server unix:/tmp/app.sock fail_timeout=0;
}
server {
listen ###.###.###.###;
server_name whatever.server;
root /web/root;
try_files $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
Run Code Online (Sandbox Code Playgroud)
一些应用服务器进程反过来在请求/tmp/app.sock
可用时将其拉出。此处使用的特定应用服务器是 Unicorn,但我认为这与此问题无关。
问题是,似乎超过一定量的负载后,nginx 无法以足够快的速度通过套接字获取请求。我设置了多少个应用服务器进程并不重要。
我在 nginx 错误日志中收到了大量这些消息:
connect() to unix:/tmp/app.sock failed (11: Resource temporarily unavailable) while connecting to upstream
Run Code Online (Sandbox Code Playgroud)
许多请求会导致状态代码 502,以及那些不需要很长时间才能完成的请求。nginx 写入队列统计数据徘徊在 1000 左右。
无论如何,我觉得我在这里遗漏了一些明显的东西,因为 nginx 和应用程序服务器的这种特殊配置非常普遍,尤其是对于 Unicorn(实际上这是推荐的方法)。是否有任何需要设置的 linux 内核选项,或者 nginx 中的某些内容?关于如何增加上游套接字的吞吐量的任何想法?我显然做错了什么?
关于环境的其他信息:
$ uname -a
Linux …
Run Code Online (Sandbox Code Playgroud) 当我运行这个:
nslookup some.host.com
Run Code Online (Sandbox Code Playgroud)
我得到这样的结果:
Server: 4.2.2.1
Address: 4.2.2.1#53
Non-authoritative answer:
Name: some.host.com
Address: #.#.#.#
Run Code Online (Sandbox Code Playgroud)
“4.2.2.1”在我的 /etc/resolv.conf 的顶部,所以这是有道理的,但这是什么#53
意思?谷歌搜索,这似乎通常附加到 nslookup 结果中的地址,但我找不到任何关于它实际含义的信息。
我正在运行 Ubuntu 11.10。
这是 my 中唯一/etc/apt/sources.list
包含文本“google”或“chrome”的行:
deb http://dl.google.com/linux/chrome/deb/ stable main
Run Code Online (Sandbox Code Playgroud)
有时(并非总是)当我运行时apt-get update
,我会在输出结束时收到这些警告:
Reading package lists... Done
W: Duplicate sources.list entry http://dl.google.com/linux/chrome/deb/ stable/main amd64 Packages (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://dl.google.com/linux/chrome/deb/ stable/main i386 Packages (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems
Run Code Online (Sandbox Code Playgroud)
如果我apt-get update
在收到这些警告后立即再次运行,它们不会第二次(或第三次,等等)出现。但是,警告最终总是会回来。
在任何情况下,安装/更新都google-chrome
可以正常工作,但这些警告很烦人(而且由于我现在略读它们,如果出现的话,我可能会无意中错过一些更重要的警告)。
有什么办法可以永久摆脱这些警告?
apt ×1
linux ×1
nameserver ×1
nginx ×1
nslookup ×1
socket ×1
tuning ×1
ubuntu ×1
ubuntu-11.10 ×1
unicorn ×1