uwsgi异常服务器内存cpu爆满优化思路

记录线上服务器通过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
posted @ 2019-12-02 10:16  py鱼  阅读(4046)  评论(0编辑  收藏  举报
点我回主页