【问题标题】:uwsgi produce a lot of strange process,just like defunct processuwsgi产生了很多奇怪的进程,就像defunct process一样
【发布时间】:2018-03-08 09:28:29
【问题描述】:

我有一个web项目,使用nginx,uwsgi,web.py,nginx用于负载均衡,uwsgi用作web服务器,web.py是web框架

我用这个command开始它“/usr/local/bin/uwsgi -d /home/sheng/www/lr-server/../log/lr-server/uwsgi.log -s 127.0.0.1:8666 -w rc_main -t 20 -M -p 20 --pidfile /home/sheng/www/lr-server/master.pid --enable-threads -R 800"

这个command表示它将产生20个进程来接收请求,每个进程最多接收800个请求

如下图为正常流程

sheng     12414 15051 21 10:04 ?        00:01:45 /usr/local/bin/uwsgi -d /home/sheng/www/lr-server/../log/lr-server/uwsgi.log -s 127.0.0.1:8666 -w rc_main -t 20 -M -p 20 --pidfile /home/sheng/www/lr-server/master.pid --enable-threads -R 800

15051 是父 pid

一般情况下可以正常工作,但是当服务器很忙,很多请求需要很长时间的时候就会产生奇怪的过程,如下图所示是奇怪的过程:

sheng     23370     1  0 09:08 ?        00:00:00 /usr/local/bin/uwsgi -d /home/sheng/www/lr-server/../log/lr-server/uwsgi.log -s 127.0.0.1:8666 -w rc_main -t 20 -M -p 20 --pidfile /home/sheng/www/lr-server/master.pid --enable-threads -R 800

你会注意到,这个进程的pid是23370,但它的父pid是1,就像一个已经死掉的进程。然而,事实上,这个进程占用了内存,不会收到任何请求

我本来希望产生20个正常的进程来接收请求,但是现在它处理了80多个starnge进程,谁能告诉我为什么以及我可以做些什么来解决这个问题

【问题讨论】:

    标签: python nginx uwsgi web.py


    【解决方案1】:

    我找到原因了

    在我的python项目中,有时python会使用R进行科学计算

    R比较慢,所以我的一个同事使用并行技术,R会fork一些子进程来计算

    不幸的是,如果一个请求超过 20 秒,uwsgi 会杀死 python 进程,但由于未知原因,那些 R 分叉的子进程不会被杀死,它们只是我看到的奇怪进程

    【讨论】:

      猜你喜欢
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 2013-09-22
      • 2011-06-20
      • 2023-03-17
      • 2020-05-14
      相关资源
      最近更新 更多