Apache 2.2.27 崩溃,CPU 占用率达 100%

Apache 2.2.27 崩溃,CPU 占用率达 100%

我们有一个处理器密集型 Web 门户,很容易达到高 CPU 使用率,当这种情况发生时,Apache (2.2.27) 服务器会崩溃,之前使用 Apache 2.2.25(带有 OpenSSL 0.9.8y)时服务器不会崩溃。下面的错误日志让我很难诊断问题的确切原因,我希望有人能给我指明正确的方向?谢谢

  • 已启用 Windows Server 2003 R2 32 位 PAE
  • Apache 2.2.27(OpenSSL 1.0.1g)
  • PHP 5.3.28
  • 16GB 内存
  • 3.33GHz 处理器(共 4 核)

第一个 Apache 错误日志

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[Fri Apr 11 15:47:24 2014] [warn] Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
[Fri Apr 11 15:47:25 2014] [crit] Parent: child process exited with status 3 -- Aborting.

将线程数增加到 1500 后的 Apache 错误日志

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[Mon Apr 14 09:20:41 2014] [crit] Parent: child process exited with status 3 -- Aborting.

事件查看器

Event Type: Error
Event Source:   Application Error
Event ID:   1000
Description:
Faulting application httpd.exe, version 2.2.27.0, faulting module msvcr90.dll, version 9.0.21022.8, fault address 0x0005bb47.

httpd配置文件

ServerRoot "C:/Apache2"

Listen 80

ThreadsPerChild 1500

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule php5_module "C:\PHP\php5apache2_2.dll"

<IfModule !mpm_netware_module>
    <IfModule !mpm_winnt_module>
        User daemon
        Group daemon
    </IfModule>
</IfModule>

ServerAdmin [email protected]
ServerName localhost
DocumentRoot "C:/Apache2/htdocs/localhost"

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName localhost
    DocumentRoot "C:/Apache2/htdocs/localhost"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.portal-alpha.com
    ServerAlias portal-alpha.com
    DocumentRoot "C:/Apache2/htdocs/portal-alpha.com"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.portal-beta.com
    ServerAlias portal-beta.com
    DocumentRoot "C:/Apache2/htdocs/portal-beta.com"
</VirtualHost>

<VirtualHost 192.168.0.2:80>
    ServerAdmin [email protected]
    ServerName sslportal.com
    DocumentRoot "C:/Apache2/htdocs/sslportal.com"
</VirtualHost>

AccessFileName .htaccess

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

ErrorLog "logs/error.log"
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access.log" common
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "C:/Apache2/cgi-bin/"
</IfModule>

<Directory "C:/Apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
</IfModule>

Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-phpmyadmin.conf

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

PHPIniDir "C:\PHP\"

httpd-ssl.conf

Listen 443

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
#SSLPassPhraseDialog  builtin
SSLSessionCache        "shmcb:C:/Apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLMutex default

<VirtualHost _default_:443>
    DocumentRoot "C:/Apache2/htdocs/localhost"
    ServerName localhost:443
    ServerAdmin [email protected]
    ErrorLog "C:/Apache2/logs/error.log"
    TransferLog "C:/Apache2/logs/access.log"
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "C:/Apache2/conf/certificates/localhost/localhost.crt"
    SSLCertificateKeyFile "C:/Apache2/conf/certificates/localhost/localhost.key"
    #SSLCertificateChainFile "C:/Apache2/conf/certificates/localhost/localhost-ca.crt"
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/Apache2/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    CustomLog "C:/Apache2/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

<VirtualHost 192.168.0.2:443>
    DocumentRoot "C:/Apache2/htdocs/ssl-portal.com"
    ServerName ssl-portal.com:443
    ServerAdmin [email protected]
    ErrorLog "C:/Apache2/logs/error.log"
    TransferLog "C:/Apache2/logs/access.log"
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "C:/Apache2/conf/certificates/ssl-portal.com.com/ssl-portal.com.crt"
    SSLCertificateKeyFile "C:/Apache2/conf/certificates/ssl-portal.com/ssl-portal.com.key"
    SSLCertificateChainFile "C:/Apache2/conf/certificates/ssl-portal.com/ssl-portal.com-ca.crt"
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/Apache2/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    CustomLog "C:/Apache2/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

httpd-phpmyadmin.conf

AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "C:/Apache2/phpmyadmin$1"

<Directory "C:/Apache2/phpmyadmin">
    Options -Indexes
    AllowOverride None
    Order deny,allow
    Allow from 127.0.0.1
    Deny from all

    LanguagePriority en de es fr ja ko pt-br ru
    ForceLanguagePriority Prefer Fallback
</Directory>

php.ini

[PHP]
engine = On
short_open_tag = On
asp_tags = Off
precision = 12
y2k_compliance = On
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 100
allow_call_time_pass_reference = On
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
error_reporting = E_ALL
display_errors = On
display_startup_errors = Off
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "EGPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = On
auto_globals_jit = On
post_max_size = 1024M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = On
file_uploads = On
upload_max_filesize = 1024M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 600
upload_tmp_dir ="C:\WINDOWS\Temp"
session.save_path ="C:\WINDOWS\Temp"
auto_detect_line_endings = On
log_errors=On
error_log="C:\WINDOWS\temp\php-errors.log"
extension_dir="C:\PHP\ext"

[Date]
date.timezone = "Europe/London"

[filter]

[iconv]

[intl]

[sqlite]
extension=php_sqlite.dll

[sqlite3]

[Pcre]

[Pdo]

[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=

[Phar]

[Syslog]
define_syslog_variables  = Off

[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On

[SQL]
sql.safe_mode = Off

[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1

[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"

[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off

[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off

[OCI8]

[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10

[bcmath]
bcmath.scale = 0

[browscap]

[Session]
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 7200
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off

[Assertion]

[COM]

[mbstring]

[gd]

[exif]

[Tidy]
tidy.clean_output = Off

[soap]
soap.wsdl_cache_enabled = 1
soap.wsdl_cache_dir = C:\WINDOWS\Temp\
soap.wsdl_cache_ttl = 86400
soap.wsdl_cache_limit = 5

[sysvshm]

[ldap]
ldap.max_links = -1

[mcrypt]

[dba]

[xsl]

[PHP_PDF]
extension=libpdf_php.dll
[PHP_SSH2]
extension=php_ssh2.dll
[PHP_UPLOADPROGRESS]
extension=php_uploadprogress.dll
uploadprogress.file.contents_template = C:\WINDOWS\Temp\upload_contents_%s
uploadprogress.file.filename_template = C:\WINDOWS\Temp\upt_%s.txt
uploadprogress.get_contents = 0
[PHP_PTHREADS]
extension=php_pthreads.dll
[PHP_EXCEL]
extension=php_excel.dll
excel.license_name=System Administrator
excel.license_key=
excel.skip_empty=
[PHP_BZ2]
extension=php_bz2.dll
[PHP_CURL]
extension=php_curl.dll
[PHP_GD2]
extension=php_gd2.dll
[PHP_GETTEXT]
extension=php_gettext.dll
[PHP_GMP]
extension=php_gmp.dll
[PHP_IMAP]
extension=php_imap.dll
[PHP_MBSTRING]
extension=php_mbstring.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
[PHP_OPENSSL]
extension=php_openssl.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
[PHP_PDO_ODBC]
extension=php_pdo_odbc.dll
[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll
[PHP_PGSQL]
extension=php_pgsql.dll
[PHP_SOAP]
extension=php_soap.dll
[PHP_SOCKETS]
extension=php_sockets.dll
[PHP_SQLITE3]
extension=php_sqlite3.dll
[PHP_TIDY]
extension=php_tidy.dll
[PHP_XMLRPC]
extension=php_xmlrpc.dll
[PHP_EXIF]
extension=php_exif.dll

相关内容