uwsgi 报MemoryError
网站部署后,基本一天有时候几个小时就会502,查看uwsgi日志看到,一直在报MemoryError的错
之前以为是python版本的问题,说是32位的python最多支持2G,但查看了python版本,是64位的啊
>>> import platform
>>> platform.architecture()
('64bit', 'ELF')
>>>
于是怀疑程序问题,内存占用到了物理内存的极限,所以加了2G虚拟内存
[root@iZbp1cixaslir6lcn0qcdvZ ~]# free -m
total used free shared buffers cached
Mem: 16081 5502 10578 0 208 3702
-/+ buffers/cache: 1591 14489
Swap: 2047 0 2047
甚至发现,系统内存使用量还不到1/3
最后查看了下uwsgi的配置文件的文档
socket : 地址和端口号,例如:socket = 127.0.0.1:50000
processes : 开启的进程数量
workers : 开启的进程数量,等同于processes(官网的说法是spawn the specified number of workers / processes)
chdir : 指定运行目录(chdir to specified directory before apps loading)
wsgi-file : 载入wsgi-file(load .wsgi file)
stats : 在指定的地址上,开启状态服务(enable the stats server on the specified address)
threads : 运行线程。由于GIL的存在,我觉得这个真心没啥用。(run each worker in prethreaded mode with the specified number of threads)
master : 允许主进程存在(enable master process)
daemonize : 使进程在后台运行,并将日志打到指定的日志文件或者udp服务器(daemonize uWSGI)。实际上最常用的,还是把运行记录输出到一个本地文件上。
log-maxsize :以固定的文件大小(单位KB),切割日志文件。 例如:log-maxsize = 50000000 就是50M一个日志文件。
pidfile : 指定pid文件的位置,记录主进程的pid号。
vacuum : 当服务器退出的时候自动清理环境,删除unix socket文件和pid文件(try to remove all of the generated file/sockets)
disable-logging : 不记录请求信息的日志。只记录错误以及uWSGI内部消息到日志中。如果不开启这项,那么你的日志中会大量出现这种记录:
[pid: 347|app: 0|req: 106/367] 117.116.122.172 () {52 vars in 961 bytes} [Thu Jul 7 19:20:56 2016] POST /post => generated 65 bytes in 6 msecs (HTTP/1.1 200) 2 headers in 88 bytes (1 switches on core 0)
log-maxsize: 日志大小,当大于这个大小会进行切分 (Byte)
log-truncate: 当启动时切分日志
发现有这两个参数
limit-as 和 roload-on-as
原来limit-as是512,也就是每个进程最大虚拟内存只有512,故试着把这个参数调大到2048,并加一个reload-on-as = 1024,在达到1024的时候重启进程双保险
于是修改配置文件如下
socket = 127.0.0.1:8888
master = true
vhost = true
no-site = true
workers = 2
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 2048
reload-on-as = 1024
buffer-size = 30000
pidfile = /var/run/uwsgi8888.pid
daemonize = /website/uwsgi8888.log
结果按照这个配置,果然不再出现MemoryError的问题了
uwsgi 报MemoryError的更多相关文章
- django启动uwsgi报错
查看uwsgi.log *** Starting uWSGI 2.0.17 (64bit) on [Thu Apr 5 17:46:15 2018] *** compiled with version ...
- Ubuntu16.04上使用Anaconda3的Python3.6的pip安装UWSGI报错解决办法
具体报错信息: lto1: fatal error: bytecode stream generated with LTO version 6.0 instead of the expected 4. ...
- python uwsgi报错epoll_ctl(): Bad file descriptor
今天安装了uwsgi+supervisord+nginx,一直访问不了 直接启动uwsgi使用nginx访问,查看有大量报错:epoll_ctl(): Bad file descriptor [cor ...
- 启动uwsgi报错error while loading shared libraries: libpcre.so.1:
启动uwsgi时候报错: [root@ richie]# /usr/bin/uwsgi --ini /usr/local/nginx/conf/uwsgi.ini /usr/bin/uwsgi: er ...
- 安装 uwsgi报错解决
背景: 安装 uwsgi时报错如下,查阅相关资料说是 python-devel的问题,于是安装之后python-devel后问题解决 报错如下: (venv) [xxxxxxx]# pip insta ...
- centos7安装uwsgi报错
错误为: [root@bogon ~]# pip install uwsgi Collecting uwsgi Using cached uwsgi-.tar.gz Installing collec ...
- uwsgi报错:listen queue of socket ...
Linux默认的socket链接为128,uwsgi默人的链接为100 需要修改系统默认的配置参数, 然后修改uwsgi配置:listen参数:1024
- Deepin下python安装uwsgi报错: Python.h:没有那个文件或目录
解决方法是安装python-dev,这是Python的头文件和静态库包 正在读取软件包列表... 完成正在分析软件包的依赖关系树 正在读取状态信息... 完成 下列软件包是自动 ...
- linux安装uwsgi,报错问题解决
uwsgi安装 uwsgi启动后出 -- unavailable modifier requested: 0 出现问题的的原因是找不到python的解释器(其他语言同理) 你使用的yum instal ...
随机推荐
- flask项目结构(四)使用sqlalchemy和alembic
简介 其实我不是啥正经人,错了,不是啥正经程序员,所能想到的估计也就码农一级吧,高级程序员,搞什么算法,什么人工智能,大数据计算…………离我还太遥远. 但是这并不妨碍我继续学习,继续写垃圾小程序. 反 ...
- Cracking The Coding Interview 5.7
//An array A[1-n] contains all the integers from 0 to n except for one number which is missing. In t ...
- 1043 输出PATest
给定一个长度不超过 104 的.仅由英文字母构成的字符串.请将字符重新调整顺序,按 PATestPATest.... 这样的顺序输出,并忽略其它字符.当然,六种字符的个数不一定是一样多的,若某种 ...
- Centos7部署kubectl命令行工具(五)
1.准备二进制包 [root@linux-node1 ~]# cd /usr/local/src/kubernetes/client/bin [root@linux-node1 bin]# cp ku ...
- SpringMVC配置及使用
SpringMVC基本配置 SpringMVC是基本请求响应模式的框架. 在项目中集成SpringMVC框架首先需要导入相关的jar包,所需包具体如下: commons-dbcp.jar common ...
- 9.Python爬虫利器一之Requests库的用法(一)
requests 官方文档: http://cn.python-requests.org/zh_CN/latest/user/quickstart.html request 是一个第三方的HTTP库 ...
- 预期结果 参数化parametrize
1.pytest.mark.parametrize装饰器可以实现测试用例参数化. 2.实例: import pytest @pytest.mark.parametrize("req,expe ...
- nginx——优化 Nginx worker 进程数
Nginx 有 Master 和 worker 两种进程,Master 进程用于管理 worker 进程,worker 进程用于 Nginx 服务 worker 进程数应该设置为等于 CPU 的核数, ...
- 2010年腾讯前端面试题学习(jquery,html,css部分)
看了牛人写的回忆文章,里面有2010年腾讯的前端面试题,里面涉及到不少基础性的问题,js部分已学习,这是jquery,html和css部分,学习一下:) 原文地址:https://segmentfau ...
- vue优势
Vue.js是一个轻巧.高性能.可组件化的MVVM库,同时拥有非常容易上手的API: 我们都知道单页面应用:页面切换快 ,首屏时间稍慢,SEO差 js 渲染 (多页面应用: 首屏时间快 ...