私はPHP 5.3を含むCentOS 6.5からPHP 7.0を含むCentOS 7.7に移行しましたが、いくつかのhttpリクエストで奇妙な動作が発生しました。
ほとんどの場合、ページとリソースは非常に高速にロードされ、時にはページ自体またはXHR要求が完了する前に約30秒間中断されます。ページ上のすべての画像、CSS、JSなどについて、ページごとにロードされるリソースは80~100個です。
私たちは2つのサーバーのhttpd.conf、php.ini、php.confを比較しましたが、ページにF5キーを押したユーザーが1人だけであるにもかかわらず、時折動作が停止する理由がわかりませんでした。この問題はhttpとhttpsの両方で発生します。 MPM Preforkの設定も試しましたが、30秒の遅延とは関係がないようです。
ログの場合、ブラウザが呼び出しを実行して停止したことを確認すると、httpアクセスログでもその呼び出しを見つけることができます。このプロセス中に、30秒間「S」状態(スリープ)になってから消えることがわかります。その後、ブラウザは応答を受け取ります。
仕様は次のとおりです。
- CentOS Linuxバージョン7.7.1908(コア)
- サーバーバージョン:Apache/2.4.6(CentOS)
- PHP 7.0.33 (cli) (ビルド: 2019年12月17日 16:44:25) (NTS)
- カール 7.68.0
ロードされたApacheモジュール:
core_module (static)
so_module (static)
http_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
allowmethods_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_anon_module (shared)
authn_core_module (shared)
authn_dbd_module (shared)
authn_dbm_module (shared)
authn_file_module (shared)
authn_socache_module (shared)
authz_core_module (shared)
authz_dbd_module (shared)
authz_dbm_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_owner_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cache_module (shared)
cache_disk_module (shared)
data_module (shared)
dbd_module (shared)
deflate_module (shared)
dir_module (shared)
dumpio_module (shared)
echo_module (shared)
env_module (shared)
expires_module (shared)
ext_filter_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
info_module (shared)
log_config_module (shared)
logio_module (shared)
mime_magic_module (shared)
mime_module (shared)
negotiation_module (shared)
remoteip_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_plain_module (shared)
slotmem_shm_module (shared)
socache_dbm_module (shared)
socache_memcache_module (shared)
socache_shmcb_module (shared)
status_module (shared)
substitute_module (shared)
suexec_module (shared)
unique_id_module (shared)
unixd_module (shared)
userdir_module (shared)
version_module (shared)
vhost_alias_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
lua_module (shared)
mpm_prefork_module (shared)
proxy_module (shared)
lbmethod_bybusyness_module (shared)
lbmethod_byrequests_module (shared)
lbmethod_bytraffic_module (shared)
lbmethod_heartbeat_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_express_module (shared)
proxy_fcgi_module (shared)
proxy_fdpass_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_scgi_module (shared)
proxy_wstunnel_module (shared)
ssl_module (shared)
systemd_module (shared)
cgi_module (shared)
php7_module (shared)
mpm_itk_module (shared)
http -V出力(MPMプリフォークを使用していることがわかります)
Server version: Apache/2.4.6 (CentOS)
Server built: Aug 8 2019 11:41:18
Server's Module Magic Number: 20120211:24
Server loaded: APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-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=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
httpd.confの関連部分 - わかりやすくするために、リストからコメントとディレクティブを削除しましたが、必要に応じて詳細を提供できます。
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
Listen 80 http
Listen 443 https
NameVirtualHost *:443
SSLStrictSNIVHostCheck off
SSLPassPhraseDialog builtin
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
Mutex default
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
<VirtualHost _default_:443>
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
Include conf.modules.d/*.conf
LoadModule mpm_itk_module modules/mod_mpm_itk.so
php.ini:
allow_url_fopen = On
allow_url_include = Off
auto_append_file =
auto_globals_jit = Off
auto_prepend_file =
bcmath.scale = 0
cli_server.color = On
date.timezone = America/New_York
default_charset = ""
default_mimetype = "text/html"
default_socket_timeout = 60
disable_classes =
disable_functions = shell_exec,system,escapeshellcmd,escapeshellarg,proc_open,popen,parse_ini_file
display_errors = On
display_startup_errors = Off
doc_root =
enable_dl = On
engine = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
expose_php = On
file_uploads = On
html_errors = On
ibase.allow_persistent = 1
ibase.dateformat = "%Y-%m-%d"
ibase.max_links = -1
ibase.max_persistent = -1
ibase.timeformat = "%H:%M:%S"
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ignore_repeated_errors = Off
ignore_repeated_source = Off
implicit_flush = Off
ldap.max_links = -1
log_errors = On
log_errors_max_len = 1024
mail.add_x_header = On
max_execution_time = 300
max_file_uploads = 50
max_input_time = 60
memory_limit = 128M
mysqli.allow_persistent = On
mysqli.cache_size = 2000
mysqli.default_host =
mysqli.default_port = 3306
mysqli.default_pw =
mysqli.default_socket =
mysqli.default_user =
mysqli.max_links = -1
mysqli.max_persistent = -1
mysqli.reconnect = Off
mysqlnd.collect_memory_statistics = Off
mysqlnd.collect_statistics = On
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.defaultbinmode = 1
odbc.defaultlrl = 4096
odbc.max_links = -1
odbc.max_persistent = -1
output_buffering = 4096
pcre.jit=0
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.ignore_notice = 0
pgsql.log_notice = 0
pgsql.max_links = -1
pgsql.max_persistent = -1
post_max_size = 200M
precision = 14
register_argc_argv = Off
report_memleaks = On
request_order = "GP"
sendmail_path = /usr/sbin/sendmail -t -i
serialize_precision = 17
session.auto_start = 0
session.cache_expire = 180
session.cache_limiter = nocache
session.cookie_domain =
session.cookie_httponly =
session.cookie_lifetime = 0
session.cookie_path = /
session.gc_divisor = 1000
session.gc_maxlifetime = 10800
session.gc_probability = 1
session.hash_bits_per_character = 5
session.hash_function = 0
session.name = PHPSESSID
session.referer_check =
session.save_handler = files
session.save_path = "/home/www/sessions"
session.serialize_handler = php
session.use_cookies = 1
session.use_only_cookies = 1
session.use_strict_mode = 0
session.use_trans_sid = 0
short_open_tag = On
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_enabled=1
soap.wsdl_cache_limit = 5
soap.wsdl_cache_ttl=86400
sql.safe_mode = Off
tidy.clean_output = Off
track_errors = Off
unserialize_callback_func =
upload_max_filesize = 200M
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
user_dir =
variables_order = "EGPCS"
zend.assertions = -1
zend.enable_gc = On
zlib.output_compression = Off