我们正在应用程序的网页上使用locust(1000个用户)执行负载测试。
实例类型: t3a.medium实例实例运行在负载均衡器后面。我们正在使用RDS Aurora数据库,它的峰值在大约70%的CPU利用率。EC2实例度量是健康的。编辑:实例内存消耗在800 MB之内,没有可用的4GB。
存在多个502 Server error: Bad Gateway错误,有时还存在500和520错误。
错误1:
2020/10/08 16:58:21 [error] 4344#4344: *41841 connect() to unix:/var/run/php/php7.2-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: <PublicIP>, server: <Domain name>, request: "GET <webpage> HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "<Domain name>"错误2(警报):
2020/10/08 19:15:11 [alert] 9109#9109: *105735 socket() failed (24: Too many open files) while connecting to upstream, client: <PublicIP>, server: <Domain name>, request: "GET <webpage> HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "<Domain name>"列出配置文件:
Nginx组态
server {
listen 80;
listen [::]:80;
root /var/www/####;
index index.php;
access_log /var/log/nginx/###access.log;
error_log /var/log/nginx/####error.log ;
server_name #####;
client_max_body_size 100M;
autoindex off;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}/etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 8096;
multi_accept on;
use epoll;
epoll_events 512;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_types text/xml text/css;
gzip_http_version 1.1;
gzip_vary on;
gzip_disable "MSIE [4-6] \.";
include /etc/nginx/conf.d/*.conf;
}/etc/php/7.2/fpm/php-fpm.conf
emergency_restart_threshold 10
emergency_restart_interval 1m
process_control_timeout 10sPhp重要参数:
user = www-data
group = www-data
listen = /run/php/php7.2-fpm.sock
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
pm = static
pm.max_children = 300/etc/安全/限制f
nginx soft nofile 30000
nginx hard nofile 50000/etc/sysctl.conf
net.nf_conntrack_max = 131072
net.core.somaxconn = 131072
net.core.netdev_max_backlog = 65535
kernel.msgmnb = 131072
kernel.msgmax = 131072
fs.file-max = 131072我们少了什么?谁能指出正确的方向吗?
发布于 2020-10-12 06:20:59
所以我们能够解决这个问题。问题是php-fpm没有访问系统资源的权限。您可能需要根据硬件规范更改值。因此,我们的最终配置如下:
在/etc/
nginx软nofile 10000
nginx硬nofile 30000
根软nofile 10000
根硬nofile 30000
www-数据软nofile 10000
www-数据硬nofile 30000
在/etc/sysctl.conf中添加
net.nf_conntrack_max = 231072
net.core.somaxconn = 231072
net.core.netdev_max_backlog = 65535
kernel.msgmnb = 231072
kernel.msgmax = 231072
fs.file-max = 70000
worker_processes汽车;
worker_rlimit_nofile 30000;
事件{ worker_connections 8096;multi_accept on;使用epoll;epoll_events 512;}
发送文件开始;
tcp_nopush启动;
tcp_nodelay启动;
keepalive_timeout 65;
gzip开始;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_types文本/xml文本/css;
gzip_http_version 1.1;
gzip_vary启动;
gzip_disable“MSIE4-6 .";
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
rlimit_files = 10000
user =www-数据
group = www-data
listen.backlog = 4096
listen.owner =www-数据
listen.group =www-数据
;listen.mode = 0660
pm =静态
pm.max_children = 1000
https://stackoverflow.com/questions/64268764
复制相似问题