my8100 / scrapydweb

Web app for Scrapyd cluster management, Scrapy log analysis & visualization, Auto packaging, Timer tasks, Monitor & Alert, and Mobile UI. DEMO :point_right:
https://github.com/my8100/files
GNU General Public License v3.0
3.12k stars 555 forks source link

scrapydweb down due to use out of memory #145

Open devxiaosong opened 4 years ago

devxiaosong commented 4 years ago

英文不好,就用中文来描述,请见谅。

连续两天Scrapydweb莫名就挂掉了,通过系统使用情况发现,是因为内存突然在某个时刻耗尽。 进而又发现,这个时间点有从网络读取了大量内容。

目前我在用单台服务器安装Scrapydweb管理其他几个爬虫服务器,并没有做其他事。所以这个网络读取肯定是来自和几个爬虫服务器的交互。进而发现,在同一个时刻有一台爬虫服务器,流出很大数据包。

简单来讲就是: 从其中一台爬虫服务器读取了大量内容 -》Scrapydweb服务器内存飙升 -》scrapydweb挂掉

现在的疑问是: 1,以上说的关联性被证实了,就不知道在什么情况下scrapydweb会从其管理的爬虫服务器读取大量内容。

我现在的几个猜测(我不了解 scrapydweb底层,只是提供点线索) 1,近一个星期有个爬虫服务任务有一次,有200+万次错误。会需要上传到scrapydweb。 2,爬虫服务器日志满了,需要传送到scrapydweb。 3,业务数据量始终大 而导致的问题?但这个问题以前没有,稳定运行4个月了,就这两天出现。

现在每天随机挂掉几次,始终影响线上业务。望作者能给予指导,如何解决这个问题!

my8100 commented 4 years ago

Make sure that logparser is running on each Scrapyd server.

devxiaosong commented 4 years ago

Of course, logparser is running on each side. If it is not running on scrapydweb server, what does happen? The server fetchs log from scrapy node server?

my8100 commented 4 years ago

Scrapydweb would fetch the original log files from Scrapyd if logparser is not running on the Scrapyd side. With logparser running, fetching stats.json files would not consuming too much bandwidth and memory. Also, make sure LOG_CATEGORIES_LIMIT is set to non-zero. https://github.com/my8100/logparser/blob/ed7948b271884af68eb3bb13fa9ee51a4892552c/logparser/settings.py#L60-L62

my8100 commented 4 years ago

这个时间点有从网络读取了大量内容。

Can you post the related logs?

Also, please check if there are files with large size in the Python path like site-packages/scrapydweb/data/stats.