为什么我的httpd mpm_prefork进程如此快速地被收割?

[编辑]

糟糕的问题,主要是 – 看到我的答案

[/编辑]

我们有一个运行RHEL6,x64的系统。 我们正在使用从本地安装的apache 2.2.22来源。 我们主要服务于:

  1. mod_perl应用程序(用本地安装的perl 5.16.0)
  2. 用mod_jk代理的tomcat应用程序

这里是一些背景; 主要问题在下面。

所有这些都与Oracle后端对话。

我们遇到了Oracle无法响应的问题。 我们认为这是因为我们正在达到oracle的最大进程限制。 我们已经提高了stream程限制,但是现在我们正面临oracle服务器的内存压力。 我们有大量的甲骨文会议闲置。 我可以跟踪一堆他们回到httpd进程。

我们有mod_perl的Apache :: DBI启动一个新的连接到数据库与每个生成的httpd子。 我们担心,当httpd的退出和httpd正在退出的时候,这些并不总是被正确地closures。 我知道修改mod_perl应用程序以使用一些更好的db连接池forms是很好的; 我们打算追求这个,但是想尽快解决我们眼前的问题。

所以这是主要的问题。

我们正在使用prefork MPM。

Apachesubprocess最多持续几分钟 。 日志分析显示,每个人在退出之前所服务的客户less于50个; 每个孩子的最后一个请求是在某种内部连接上的OPTIONS * HTTP/1.0 ; 我的印象是这是一个从主进程“平”。

我已经调整了MPMconfiguration如下。 我不想提高MinSpareServers太高,因为毕竟,我试图最大限度地减less对oracle的会话数量。

 MinSpareServers 5 MaxSpareServers 30 MaxClients 150 MaxRequestsPerChild 10000 

现在我们每分钟服务250-300个请求。

我们有21个httpd正在运行,其中最年长的(除了拥有root权限的主人)还有3分钟的时间。

这个apache儿童的收获率似乎过高。 什么可能导致它?

Apachebuild立于:

  $ ./configure --prefix=/opt/apache --with-ssl=/usr/lib --enable-expires --enable-ext-filter --enable-info --enable-mime-magic --enable-rewrite --enable-so --enable-speling --enable-ssl --enable-usertrack --enable-proxy --enable-headers --enable-log-forensic 

Apacheconfiguration信息:

 % /opt/apache/bin/httpd -V Server version: Apache/2.2.22 (Unix) Server built: Jul 23 2012 22:30:13 Server's Module Magic Number: 20051115:30 Server loaded: APR 1.4.5, APR-Util 1.4.1 Compiled using: APR 1.4.5, APR-Util 1.4.1 Architecture: 64-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/opt/apache" -D SUEXEC_BIN="/opt/apache/bin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" 

模块被编译成apache而不是共享库:

 % /opt/apache/bin/httpd -l Compiled in modules: core.c mod_authn_file.c mod_authn_default.c mod_authz_host.c mod_authz_groupfile.c mod_authz_user.c mod_authz_default.c mod_auth_basic.c mod_ext_filter.c mod_include.c mod_filter.c mod_log_config.c mod_log_forensic.c mod_env.c mod_mime_magic.c mod_expires.c mod_headers.c mod_usertrack.c mod_setenvif.c mod_version.c mod_proxy.c mod_proxy_connect.c mod_proxy_ftp.c mod_proxy_http.c mod_proxy_scgi.c mod_proxy_ajp.c mod_proxy_balancer.c mod_ssl.c prefork.c http_core.c mod_mime.c mod_status.c mod_autoindex.c mod_asis.c mod_info.c mod_cgi.c mod_negotiation.c mod_dir.c mod_actions.c mod_speling.c mod_userdir.c mod_alias.c mod_rewrite.c mod_so.c 

最后一点 – 红帽httpd,apr和perl软件包都已经安装完毕,但ldd显示这些库都没有与正在运行的httpd链接。

aaargh

在这种情况下的答案是,我没有configuration与这些maxrequestsperchild,minspareservers和maxspareservers选项的Apache。

我修改了一个configuration文件,我相信是在主文件中Include d,但没有。 新的这个网站,和旧的configuration。 叹。

所以,我描述的行为是编译默认(我三重检查;它不会被设置在其他地方)。 文档build议这些是编译的默认值:

http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxrequestsperchild

http://httpd.apache.org/docs/2.2/mod/prefork.html

 MaxRequestsPerChild 10000 MaxSpareServers 10 MinSpareServers 5 

我认为我看到的行为不符合这些违约。 我将用apache提交一个bug。

我想这仍然是一个有用的问题留在网站上,因为默认行为不符合文档。 如果别人不同意,我会很高兴地结束我的问题。