Nginx延迟太高

时间:2018-03-04 20:22:26

标签: php nginx connection response

我使用2台服务器用于php和mysql。 用户通过Cloudflare连接>清漆> Ngnix> Php-fpm - > Mysql Server 但是我直接将我的网站与nginx端口连接起来,这是相同的

我的服务器属性是16 GB ram,E3-1231v3 cpu(8核心) 服务器负载总是1.30,免费内存是3 gb但是在周末,我的网站得到了大量的流量,有时网站响应很晚,它喜欢冻结。 当我检查php-fpm和nginx连接时,php-fpm通常是30-40,但它已经看到最大650。 Nginx通常是100,但有时会达到400-500-600并且开始冻结,我看到写连接同时与nginx连接增加相同,并且网站响应变得迟到。

我设置了munin并监控了nginx,php-fpm和网络,就像那样。

s s s s s

我的nginx就像那样

user www-data;
worker_processes auto;
pid /var/run/nginx.pid;

error_log  /var/log/nginx/error.log info;
worker_rlimit_nofile 65536;

events {
worker_connections 65536;
use epoll;
multi_accept on;
}

http {

##
# Basic Settings
##
log_format  main  '$http_cf_connecting_ip - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
log_format combined2 '$http_cf_connecting_ip - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';

sendfile on;
keepalive_timeout 15; #65;
keepalive_requests 100000;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
# server_tokens off;
client_body_buffer_size 10K; #15M;
client_max_body_size 10M;

# send_timeout 10;
client_header_buffer_size 10k;
large_client_header_buffers 2 10k;
output_buffers 1 32k;
postpone_output 1460;
client_header_timeout  12; #4m;
client_body_timeout    12; #4m;
send_timeout           10; #4m;
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 5;
open_file_cache_errors off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log off; #/var/log/nginx/access.log;
error_log off; #/var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

gzip_vary on;
# gzip_proxied any;
gzip_comp_level 2;
gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream backend {
server 127.0.0.1:9000;
}

real_ip_header X-Forwarded-For;
# Cloudflare
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
real_ip_header CF-Connecting-IP;
real_ip_header X-Forwarded-For;
}

我怀疑网络带宽和nginx配置,你有什么想法吗?

0 个答案:

没有答案