我们刚刚从带有 PHP 5.3 的 CentOS 6.5 迁移到带有 PHP 7.0 的 CentOS 7.7,并且在一些 http 请求中出现了奇怪的行为
大多数时候,页面和资源加载速度非常快,而有时,页面本身或 XHR 请求将在完成之前挂起大约 30 秒。对于页面上的所有图像、CSS、JS 等,每个页面加载有 80 到 100 个资源。
我们比较了两台服务器的 httpd.conf、php.ini 和 php.conf,我们无法弄清楚为什么它有时会挂起,即使我们只有一个用户 F5-ing 页面。 http 和 https 都会出现此问题。我们还尝试过设置 MPM Prefork,但它似乎与 30 秒延迟无关
至于日志,一旦浏览器执行调用并且我们看到它挂起,我们也可以在http访问日志中找到该调用。在这个过程中,我们可以看到它处于“S”状态(睡眠)30秒,然后它就消失了……然后浏览器也得到了响应。
以下是规格:
- 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 prefork)
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