`
nigelzeng
  • 浏览: 599803 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

关于httpd <defunct>进程的简略理解

阅读更多

今天无意中查看到了一个apache+php的服务器上出现了很多httpd <defunct> 进程。

第一次见到这个名字的进程,于是查阅了相关资料。

记录一下我理解到的httpd <defunct>:

 

1、什么是httpd <defunct>

defunct进程实际上是‘zombies’进程(top里查看到标记为‘Z’的进程)。

当一个进程执行完毕、结束后,需要其父进程来读取自己的状态,才能完全结束,这期间,如果父进程一直没有来读取状态,那么这个执行完毕的进程会一直在进程表中占据一个条目,这个时候的进程就是 'defunct' 进程。

 

更多的内容介绍可以查看:http://en.wikipedia.org/wiki/Zombie_process

 

 

2、为什么会产生httpd <defunct>进程

 

    默认情况下,apache的设置是:一个工作进程执行完指定数目的请求后,主进程会结束掉这个工作进程。这样设计是为了不至于内存泄漏,从而导致失控。

    第一种情况:像前面所说的,apache的主进程会对“寿终正寝”的工作进程进行回收。然而当服务器负载(load)很高时,apache的主进程可能没有空闲的时间去执行这一步回收工作。从而导致这些没有回收的“寿终正寝”的工作进程以‘defunct’的姿态出现在top命令里。在这种情况下出现‘defunct’进程是不用太担心的,除非有超大量的‘defunct’进程。

 

    另一种可能的情况是:工作进程异常退出导致的,异常退出的原因可能有很多,比如web应用的代码里有bug,或者web应用的引擎有bug。这种情况,可以通过查看apache的error_log日志来查看,查找是否有严重的错误日志打印出来。

 

我碰到的情况都不是上面两种,所以我又查了更多的资料,比如这个:

 

BiGWill 写道(链接:点击这里
Thanks all for your help....
I finally nailed it down to the access_log which was 2GB big, which is the limit of the file system!

Guess i should implement some logrotation :D

Thanks everyone for their suggestions/help!

regards,

 

他说的是日志文件达到2G的上限,导致出现httpd <defunct> 进程,我这里使用的是cronolog来按天切割日志,每个日志文件才几十M,所以这个也不是想要的。

 

再比如这个:

 

gulaizi 写道(链接在这里:点击跳转
问题的原因不会apache的问题,而是php版本的兼容性问题。
介于这个问题,我开始察看PHP问题,终于发现是php我安装了mmcahe,而且mmcache已经很久之前就停止开发了,对linux x86-64有兼容性问题。去掉mmcache,问题解决。

 

还有这个同学的描述:点击这里

 

都不符合我机器上的环境,所以我索性重启了一下apache,然后问题就解决了,很匪夷所思。原因依然待查……

 

最后,贴一段对系统管理员有用的,对“defunct”进程本质的解释:

 

来源:Yahoo Answers
The below explains what <defunct> means. If you aren't a Unix system administrator, this may not be of interest to you.

Normally, when a process exits (normally or abnormally), it enters a state known as “zombie” (which in top appears as Z). Its process ID stays in the process table until its parent waits on (or “reaps”) it. Under normal circumstances, when the parent process fully expects its child processes to exit, it sets up a signal handler for SIGCHLD so that, when the signal is sent (upon a child process's exit), the parent process then reaps it at its convenience.

If the parent process has hung for some reason, such as if it's suspended, or is too busy, or is deadlocked, then child processes that exit will not be reaped (until the parent process resumes again). This can cause serious problems if there are many child processes, occupying slots in the process table that will not be freed.

In that case, one solution (if the parent process is unrecoverable, say), is to kill the parent process. Then, the child processes will be reparented to the init process (process ID 1), which will reap them. (If the init process is stalled, then you have much, much bigger problems than child processes not being reaped. In fact, a crashed init process will usually cause a kernel panic.)

 

-----EOF------

分享到:
评论

相关推荐

    Practical Mod Perl

    Practical Mod Perl&lt;br&gt;&lt;br&gt; Copyright &lt;br&gt; Preface &lt;br&gt; What You Need to Know &lt;br&gt; Who This Book Is For &lt;br&gt; How This Book Is Organized &lt;br&gt; Reference Sections &lt;br&gt; Filesystem Conventions &lt;br&gt; Apache ...

    php配置+mysqlAdmin配置+apache配置的实现教程

    &lt;br&gt; apache的配置文件\conf\httpd.conf&lt;br&gt; apache的默认的项目存放目录\htdocs\&lt;br&gt;&lt;br&gt;2)apache的一些常用配置(http.conf) &lt;br&gt;&lt;br&gt; 1。 &lt;br&gt; 关键字“DocumentRoot”(也就是网站根目录).注意:“\”在Apache...

    wlmp 绿色包

    &lt;br&gt;&lt;br&gt;&lt;br&gt;@copyright 2007-2008 http://hi.baidu.com/sleets&lt;br&gt;&lt;br&gt;软件版本 &lt;br&gt; php 5.2.6&lt;br&gt; lighttpd 1.4.16&lt;br&gt; mysql 4.1.22&lt;br&gt; phpmyadmin 2.11.8.1&lt;br&gt;&lt;br&gt;如何开启Zend Optimizer&lt;br&gt; 去掉 .\etc\...

    linux目录架构

    &lt;br&gt; /var/log/maillog 紀錄郵件存取或往來( sendmail 與 pop3 )的使用者記錄 &lt;br&gt; /var/log/cron 記錄 crontab 這個例行性服務的內容 &lt;br&gt; /var/log/httpd, /var/log/news, /var/log/mysqld.log, /var/log/samba, /...

    X3BLOG v0.7.5.0

    关于 X3-BLOG&lt;br&gt;&lt;br&gt; X3-BLOG 是基于XML+XSLT+AJAX技术构建的开源多用户博客门户系统,服务器端采用当前最流行的动态网页开发语言ASP.NET(C#) &lt;br&gt;&lt;br&gt;2.0编写,支持多种数据库,包括SQLSERVER2000\SQLSERVER2005\...

    awk.exe

    &lt;br&gt;&lt;br&gt;ps:&lt;br&gt;本人在win2003r2 sp2上用vc6编译apache httpd2.2.4时出现错误:&lt;br&gt;Support for LDAP v2.0 toolkits has been removed from apr-util. Please use an LDAP v3.0 toolkit.&lt;br&gt;解决方案:&lt;br&gt;httpd-...

    .htaccess

    &lt;br&gt;&lt;br&gt;Part 1 – Introduction介绍 &lt;br&gt;Part 2 - .htaccess Commande命令 &lt;br&gt;Part 3 - Password protection密码保护 &lt;br&gt;Part 1 – Introduction介绍&lt;br&gt;&lt;br&gt;Introduction 介绍&lt;br&gt;&lt;br&gt;In this tutorial you will...

    URL处理引擎

    &lt;br&gt;&lt;br&gt;&lt;br&gt;下面附上几个通用的配置正则表达式,笔者试用通过: &lt;br&gt;&lt;br&gt;例子:http://music.caiku.com http://flash.caiku.com &lt;br&gt;&lt;br&gt;文件名、参数、参数值均在20位以内 &lt;br&gt;&lt;br&gt;一个参数通用表达式:/(.{1,20}...

    Tomcat5027_Apache2048_IMS9_win.zip

    &lt;br&gt;用文本编辑工具打开Apache安装目录下的conf子目录下的httpd.conf文件,在#LoadModule ssl_module modules/mod_ssl.so语句下面增加以下语句:LoadModule jk2_module modules/mod_jk2.so ,这就使mod_jk2在Apache...

    httpd-2.4.28

    &lt;If&gt;, &lt;ElseIf&gt;, and &lt;Else&gt; sections can be used to set the configuration based on per-request criteria. General-purpose expression parser A new expression parser allows to specify complex conditions ...

    深入apache配置文件httpd.conf的部分参数说明

    &lt;Directory&gt;…&lt;/Directory&gt; — 设定指定目录的访问权限&lt;Files&gt;…&lt;/Files&gt; — 设置应用于指定文件的指令示例:拒绝访问以‘-ht’开头的文件&lt;Files&gt;Order allow,denyDeny from all&lt;/Files&gt;&lt;Location&gt;…&lt;/Location&gt; — ...

    discuz_iis_rewrite

    伪静态软件&lt;br&gt;在IIS的Isapi上添加这个筛选器&lt;br&gt;筛选器名称Rewrite&lt;br&gt;可执行文件选择 Rewrite.dll 即可以了&lt;br&gt;&lt;br&gt;httpd.ini是配置文件,应该不要我多说了吧,很简单的

    文件防盗链示例源码

    &lt;add verb="*" path="*.gif" type="WebApplication1.httpd"/&gt; &lt;/httpHandlers&gt; 如有多个需防链接类型 添加多个add节点 WebApplication1表示项目命名空间 Httpd表示 一个hddpd.ashx文件 在项目根路径下

    apache-mod-diary

    mod_diary-Apache HTTPD服务器的简单博客系统 演示博客 依存关系 折扣 透明银 对于Debian: # apt-get install libmarkdown2-dev clearsilver-dev 建造 % autoreconf -i % ./configure --with-apxs=...&lt;Location&gt;

    discuz的rewrite规则下载

    适用于Discuz!的Rewrite规则的正则表达式&lt;br&gt;&lt;br&gt;使用方法:&lt;br&gt;将以上代码复制到记事本中,然后另存为“httpd.ini”文件,最后覆盖掉服务器上的“httpd.ini”文件即可

    apache部署文件

    Knauf &lt;fuankg@apache.org&gt; Requirements : LIBC 8.0 (2004/09/22 or later), available at: http://developer.novell.com/wiki/index.php/Libraries_for_C_(LibC) for authldap LDAP libs (2004/02/18 or later), ...

    httpd-mock:Node.js 的 httpd-mock 运行一个 http 静态服务器。 支持模拟 API 实现

    httpd-mock [-c, --config &lt;path&gt;] [-O, --output] [-p &lt;port&gt;] [-r &lt;rootpath&gt;] 如果您提供的配置文件和命令行参数发生冲突,这些参数将被覆盖。 配置文件 包含以下结构的 JSON 文件: { "serverRootPath" : "./...

    apache2.2 与 svn1.6 整合所需要的 svn module 文件

    4 增加/svn的&lt;Location&gt;,(假设通过extra/httpd-vhosts.conf配置了vhost,则在httpd-vhosts.conf的&lt;VirtualHost&gt;中) &lt;Location /svn&gt; DAV svn # 指向SVN Repository的ROOT SVNPath d:/svnrepo &lt;/Location&gt;

    DirectorySearcher:在目录树中搜索

    &lt;threads&gt; 工作线程中的进程文件。 找到后立即将找到的条目 [文件绝对路径,文件中字符串的绝对位置] 打印到标准输出中。 在流程结束时打印总体统计信息 (不包括预热和 GC 阶段)。 测试在 4 处理器计算机上...

    IIS服务器SSI(rewrite重写)插件的帮助资料

    不支持&lt;VirtualHost&gt;、&lt;Directory&gt;、&lt;DirectoryMatch&gt;、&lt;Files&gt;、&lt;FilesMatch&gt;、&lt;Location&gt; 以及&lt;LocationMatch&gt;这几个标签。 ? 精简版中没有代理服务模块,因而所有的和代理服务功能相关的比如说RewriteProxy指令...

Global site tag (gtag.js) - Google Analytics