524 超时错误与多个连接
524 time out error with mutiiple connections
我正在使用 JMeter 测试服务器性能,以模拟大量用户在短时间内访问我们的数字海洋服务器。当我将 JMeter 设置为 200 个用户并针对我基于 Laravel 的网页进行测试时,一切正常。当我将用户数增加到 500 时,我开始收到 524 错误。
服务器CPU从不超过10%,内存在30%,所以服务器有足够的电量。前几百个请求处理正确,但随后开始出现 524 错误。如该屏幕截图所示,失败的请求比成功的请求具有更高的延迟和连接。我应该从哪里开始寻找问题的任何线索?
可用站点中的我的 conf 文件
位置 ~.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/xxxxxxxxxxxx.com.sock;
fastcgi_index index.php;
}
我的 nginx.conf 设置
fastcgi_buffers 8 128k;
fastcgi_buffer_size 256k;
client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
client_max_body_size 32m;
我的 /etc/sysctl.conf 文件设置,取自此 post 之前收到 504 错误 https://www.digitalocean.com/community/questions/getting-nginx-fpm-sock-error
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
### GENERAL NETWORK SECURITY OPTIONS ###
# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2
# Allowed local port range
net.ipv4.ip_local_port_range = 2000 65535
# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15
# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
### TUNING NETWORK PERFORMANCE ###
# Default Socket Receive Buffer
net.core.rmem_default = 31457280
# Maximum Socket Receive Buffer
net.core.rmem_max = 12582912
# Default Socket Send Buffer
net.core.wmem_default = 31457280
# Maximum Socket Send Buffer
net.core.wmem_max = 12582912
# Increase number of incoming connections
net.core.somaxconn = 65535
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65535
# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65535 131072 262144
net.ipv4.udp_mem = 65535 131072 262144
# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65535 16777216
net.ipv4.udp_wmem_min = 16384
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
将此添加到 /etc/security/limits.conf
nginx soft nofile 2097152
nginx hard nofile 2097152
www-data soft nofile 2097152
www-data hard nofile 2097152
我的 php-fpm.d 配置文件设置
pm = static
pm.max_children = 40
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 8
; number of processes to process before respawning. Lower number if you have memory leaks, but each respawn takes time
pm.max_requests=50
; pm.process_idle_timeout=10
chdir = /
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = on
php_admin_flag[log_errors] = on
php_admin_value[post_max_size] = 8M
php_admin_value[upload_max_filesize] = 8M
HTTP 524 错误 are cloudflare specific - 它们不是由您自己的 nginx 安装生成的。 Cloudflare 放弃等待您的后端服务的响应,可能是因为可用于处理请求的 fpm 子级数量很少。
524 A Timeout Occurred
Cloudflare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.
如果您要对自己的服务器设置进行性能测试,请不要通过指向 cloudflare 的端点。
http 服务器的一般“后端超时”响应是 504 网关超时。
我正在使用 JMeter 测试服务器性能,以模拟大量用户在短时间内访问我们的数字海洋服务器。当我将 JMeter 设置为 200 个用户并针对我基于 Laravel 的网页进行测试时,一切正常。当我将用户数增加到 500 时,我开始收到 524 错误。
服务器CPU从不超过10%,内存在30%,所以服务器有足够的电量。前几百个请求处理正确,但随后开始出现 524 错误。如该屏幕截图所示,失败的请求比成功的请求具有更高的延迟和连接。我应该从哪里开始寻找问题的任何线索?
可用站点中的我的 conf 文件
位置 ~.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/xxxxxxxxxxxx.com.sock;
fastcgi_index index.php;
}
我的 nginx.conf 设置
fastcgi_buffers 8 128k;
fastcgi_buffer_size 256k;
client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
client_max_body_size 32m;
我的 /etc/sysctl.conf 文件设置,取自此 post 之前收到 504 错误 https://www.digitalocean.com/community/questions/getting-nginx-fpm-sock-error
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
### GENERAL NETWORK SECURITY OPTIONS ###
# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2
# Allowed local port range
net.ipv4.ip_local_port_range = 2000 65535
# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15
# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
### TUNING NETWORK PERFORMANCE ###
# Default Socket Receive Buffer
net.core.rmem_default = 31457280
# Maximum Socket Receive Buffer
net.core.rmem_max = 12582912
# Default Socket Send Buffer
net.core.wmem_default = 31457280
# Maximum Socket Send Buffer
net.core.wmem_max = 12582912
# Increase number of incoming connections
net.core.somaxconn = 65535
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65535
# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65535 131072 262144
net.ipv4.udp_mem = 65535 131072 262144
# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65535 16777216
net.ipv4.udp_wmem_min = 16384
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
将此添加到 /etc/security/limits.conf
nginx soft nofile 2097152
nginx hard nofile 2097152
www-data soft nofile 2097152
www-data hard nofile 2097152
我的 php-fpm.d 配置文件设置
pm = static
pm.max_children = 40
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 8
; number of processes to process before respawning. Lower number if you have memory leaks, but each respawn takes time
pm.max_requests=50
; pm.process_idle_timeout=10
chdir = /
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = on
php_admin_flag[log_errors] = on
php_admin_value[post_max_size] = 8M
php_admin_value[upload_max_filesize] = 8M
HTTP 524 错误 are cloudflare specific - 它们不是由您自己的 nginx 安装生成的。 Cloudflare 放弃等待您的后端服务的响应,可能是因为可用于处理请求的 fpm 子级数量很少。
524 A Timeout Occurred
Cloudflare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.
如果您要对自己的服务器设置进行性能测试,请不要通过指向 cloudflare 的端点。
http 服务器的一般“后端超时”响应是 504 网关超时。