記錄線上服務器通過linux性能檢測工具glances檢測到 cpu、內存爆滿,且是uwsgi進程占用,對於服務器內核,以及uwsgi配置優化
參考文章
https://blog.csdn.net/orangleliu/article/details/48531759
uwsgi.log日志報錯
Tue Jun 2 17:33:27 2015 - *** uWSGI listen queue of socket "127.0.0.1:9080" (fd: 3) full !!! (101/100) ***
Tue Jun 2 17:33:28 2015 - *** uWSGI listen queue of socket "127.0.0.1:9080" (fd: 3) full !!! (101/100) ***
解決思路:
1.修改內核配置
2.修改uwsgi配置
內核修改
#對於一個經常處理新連接的高負載 web服務環境來說,默認的 128 太小了
net.core.somaxconn = 262144
#表示SYN隊列的長度,默認為1024,加大隊列長度為8192,可以容納更多等待連接的網絡連接數
net.ipv4.tcp_max_syn_backlog = 8192
#網卡設備將請求放入隊列的長度
net.core.netdev_max_backlog = 65536
修改完成之后要記得 sysctl -p 重新加載內核參數
uwsgi修改
修改uwsgi.ini
listen=1024
重啟uwsgi
新版uwsgi配置文件,着實好用
# 緩存體系
cache = true
cache2 = name=mycache,items=100
lazy-apps = true
wsgi-disable-file-wrapper = true
memory-report = true
uid = www
master = true
vhost = true
no-stie = true
workers = 10
reload-mercy = 10
vacuum = true
max-requests = 3500
limit-as = 1024
buffer-size = 65535
pidfile = /var/run/uwsgi.pid
master-fifo = /tmp/uwsgififo
#daemonize = /var/log/logs/uwsgi.log
logto = /var/log/logs/uwsgi.log
log-maxsize = 10000000000
enable-threads=true
die-on-term=true
wsgi-disable-file-wrapper=true
env= LUFFY_ENV=Production
ksm=10
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true
harakiri = 30
thunder-lock = True
