Python nginx在100套接字连接后无法连接到uwsgi
我们将docker用于flask应用程序,我们使用的是nginx uwsgi图像 Docker映像在大多数应用程序中都可以正常工作,但其中一个部署在某些时候会出现错误 实际误差为Python nginx在100套接字连接后无法连接到uwsgi,python,docker,nginx,flask,uwsgi,Python,Docker,Nginx,Flask,Uwsgi,我们将docker用于flask应用程序,我们使用的是nginx uwsgi图像 Docker映像在大多数应用程序中都可以正常工作,但其中一个部署在某些时候会出现错误 实际误差为 2020/10/21 18:17:49 [error] 12#12: *142201 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, clien
2020/10/21 18:17:49 [error] 12#12: *142201 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 10.255.0.212, server: , request: "GET /healthcheck HTTP/1.0", upstream: "uwsgi://unix:///tmp/uwsgi.sock:"
错误显示,uwsgi
socket存在问题。当我检查与uwsgi插座的连接时,我得到了带有连接标签的101
连接
root@eaf23a900022:/app# netstat -nap | grep uwsgi | grep CONNECTING | wc -l
101
root@eaf23a900022:/app# netstat -nap | grep uwsgi | grep CONNECTING
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
unix 2 [ ] STREAM CONNECTING 0 - /tmp/uwsgi.sock
由此看来,nginx
连接到uwsgi
,然后它无法释放它
还有其他flask应用程序在同一个映像中运行,我检查了我得到的连接插座的数量,但其他容器返回了0
root@466d15de99c7:/app# ps aux | grep uwsgi
root 10 0.3 0.2 298340 44636 ? Sl Oct17 11:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 36 0.0 0.2 298340 42776 ? S Oct18 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 37 0.0 0.2 298340 43316 ? S Oct18 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 320 0.0 0.0 12848 960 pts/0 S+ 17:23 0:00 grep uwsgi
root@466d15de99c7:/app# kill -9 10 36 37
root@466d15de99c7:/app# ps aux | grep uwsgi
root 321 43.0 0.3 222368 49872 ? D 17:24 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 325 0.0 0.0 12848 960 pts/0 S+ 17:24 0:00 grep uwsgi
root@466d15de99c7:/app# ps aux | grep uwsgi
root 321 23.5 0.3 298476 52380 ? Sl 17:24 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 327 0.0 0.2 298476 43728 ? S 17:24 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 328 0.0 0.2 298476 43728 ? S 17:24 0:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
root 330 0.0 0.0 12848 960 pts/0 S+ 17:24 0:00 grep uwsgi
root@466d15de99c7:/app# netstat -nap | grep uwsgi | grep CONNECTING | wc -l
0
在这个系统中有一些NGINX
调优参数集<代码>打印环境
输出如下
[nile2691@983195-dfw301web02 ~]$ docker exec -it b2cff9ac29a2 printenv
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=b2cff9ac29a2
TERM=xterm
API_PASS=XXXXX
API_USER=XXXX
APP_ENVIRONMENT=bleeding
BCAPI_URL=https://example.com
BSAPI_APP=RpcApi
BSAPI_DB_NAME=RPC_Bleeding
BSAPI_DB_URI=mongodb://username:mongodb.instance:26200/database?ssl=true
BSAPI_ES_LOGGING=True
BSAPI_REDIS_URI=redis://:password@redis.instance:6379/0
BSNOTIFY_ENV=staging
CELERY_BROKER_URL=amqp://username:password@rabbit.instance/vhostg
NGINX_WORKER_CONNECTIONS=2048
NGINX_WORKER_OPEN_FILES= 2048
NGINX_WORKER_PROCESSES=8
LANG=C.UTF-8
GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
PYTHON_VERSION=3.7.4
PYTHON_PIP_VERSION=19.2.1
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/404c9418e33c5031b1a9ab623168b3e8a2ed8c88/get-pip.py
PYTHON_GET_PIP_SHA256=56bb63d3cf54e7444351256f72a60f575f6d8c7f1faacffae33167afc8e7609d
NGINX_VERSION=1.15.8-1~stretch
NJS_VERSION=1.15.8.0.2.7-1~stretch
UWSGI_INI=/app/uwsgi.ini
UWSGI_CHEAPER=2
UWSGI_PROCESSES=16
NGINX_MAX_UPLOAD=0
LISTEN_PORT=80
STATIC_URL=/static
STATIC_PATH=/app/static
STATIC_INDEX=0
PYTHONPATH=/app
HOME=/root
我们正在试图理解为什么套接字连接卡在连接中
并且在请求完成后不清晰
是什么使此套接字队列达到101
计数
当它到达100+
时,它开始给出套接字错误
我们可以增加队列大小,但我们确信,它将再次满