새로운 CentOS 7 + Apache 설치 시 HTTP 요청이 중단됩니다. TTFB 30초

새로운 CentOS 7 + Apache 설치 시 HTTP 요청이 중단됩니다. TTFB 30초

방금 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 키를 누른 사용자가 한 명뿐임에도 불구하고 가끔 작동이 멈추는 이유를 알 수 없었습니다. 이 문제는 http와 https 모두에서 발생합니다. MPM Prefork 설정도 시도했지만 30초 지연과 관련이 없는 것 같습니다.

로그의 경우, 브라우저가 호출을 수행하고 정지된 것을 확인하면 http 액세스 로그에서도 해당 호출을 찾을 수 있습니다. 이 프로세스 동안 우리는 그것이 30초 동안 "S" 상태(잠자기)에 있다가 사라지는 것을 볼 수 있습니다. 그런 다음 브라우저는 응답을 받습니다.

TTFB 메모

사양은 다음과 같습니다.

  • 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

로드된 아파치 모듈:

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

관련 정보