2013年11月7日

Solve Resource temporarily unavailable

nginx error log
connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream

目前的配置是 Django, uwsgi, nignx
先看這篇好文
http://blog.forwxp.com/system-design/2013/03/12/nginx-502-with-uwsgi-in-high-request-rate/
#define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ 所以結論 return code 11 關鍵似乎是 uwsgi listen queue 滿了
但是這個其實是系統問題, os tuning
echo 3000 > /proc/sys/net/core/netdev_max_backlog echo 3000 > /proc/sys/net/core/somaxconn 或是 vi /etc/sysctl.conf net.core.somaxconn = 4096 net.core.netdev_max_backlog = 50000 sudo sysctl -p 或是 sudo sysctl -w net.core.somaxconn=4096 解釋 socketMaxListenConnections Definition: The maximum length of the TCP listen queue backlog of incoming connections requests for the socket used by the GPFS listen thread. Default Value: AIX: 1024 Linux: 128 Minimum and Maximum Value: 1 and 65536 Recommended Value: Set the value of socketMaxListenConnections greater than or equal to the number of nodes that will create a TCP connection to any one node. Additional OS Tuning: AIX: The command no p -o somaxconn must also be used to increase the value of somaxconn to a value greater than or equal to the value of socketMaxListenConnections. Linux: The sysctl.conf file must be modified to increase the value of net.core.somaxconn to a value greater than or equal to socketMaxListenConnections. Notes: Incoming connection requests may be silently dropped by the kernel networking component if the GPFS listen queue backlog is exceeded. When many nodes are TCP connecting to a node, a TCP connect may fail if the connection request is dropped too many times. The GPFS node calling connect will then send an expel request.

最後這個 tuning 還是沒有解決問題,我改用一般 port for nginx/uwsgi



沒有留言:

張貼留言