Здравствуйте всем.
Анамнез:
Захожу на VPS по SSH, врубаю htop, в браузере при переходе на сайт или с одной страницы сайта на другую наблюдаю в htop резкий всплеск нагрузки на cpu до 15%. Получается 7 одновременных запросов страниц сайта сервер могут положить?
Железо:
Xeon 1x2,4Ghz, RAM 1GB DDR4, HDD 5GB SSD.
Софт:
Debian 7, Nginx 1.10.3, PHP5-FPM 5.4.45-0+deb7u6, MySQL 5.5.54-0+deb7u1.
Сайт на WordPress.
Вопроса два:
Почему происходит всплеск нагрузки на процессор при запросе страниц сайта?
Как этот всплеск убрать или снизить?
Сильно подозреваю, что я что-то не докрутил в настройках. Поэтому прошу помощи у более опытных админов серверов и web-мастеров. Заранее спасибо.
nginx.conf
# Server globals
user admin;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
#Disable SSLv3 - CVE-2014-3566: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-3566
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Main settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_header_timeout 1m;
client_body_timeout 1m;
client_header_buffer_size 2k;
client_body_buffer_size 256k;
client_max_body_size 8m;
large_client_header_buffers 4 8k;
send_timeout 30;
keepalive_timeout 60 60;
reset_timedout_connection on;
server_tokens off;
server_name_in_redirect off;
server_names_hash_max_size 512;
server_names_hash_bucket_size 512;
# Log format
log_format main '[$time_local] $host $server_addr $remote_addr $status $body_bytes_sent $request_time $request $http_referer $http_user_agent';
access_log /var/log/nginx/access.log main;
# Mime settings
include /etc/nginx/mime.types;
default_type text/html;
# Compression
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_min_length 1024;
gzip_comp_level 5;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/atom+xml application/rdf+xml image/svg+xml application/x-font-ttf font/opentype;
# Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
# FastCGI settings
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
# Cache
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
proxy_cache_key "$host$request_uri $cookie_user";
proxy_temp_path /var/cache/nginx/temp;
proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header http_502;
proxy_cache_valid any 3d;
map $http_cookie $no_cache {
default 0;
~SESS 1;
~wordpress_logged_in 1;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
include /etc/nginx/blockips.conf;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
}
/etc/nginx/conf.d/default.conf;
# Default server
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Load default error page if not secified
include /etc/nginx/error-pages.conf;
}
/etc/nginx/sites-enabled/sitename.conf;
server {
listen ip_сервера:80;
server_name sitename.ru www.sitename.ru;
root /var/www/admin/www/sitename.ru/;
index index.php index.html index.htm;
#access_log /var/www/admin/logs/sitename.ru.access.log;
access_log off;
error_log /var/www/admin/logs/sitename.ru.error.log;
include /etc/nginx/wp-supercache.conf;
include /etc/nginx/expires.conf;
location ~* /wp-includes/js/tinymce/wp-tinymce.php {
include /etc/nginx/php-fpm.conf;
}
location ~* /(cgi-bin|wp-content|wp-includes)/.+\.php$ {
deny all;
}
location ~* /wp-login.php {
limit_req zone=login burst=3;
auth_basic "staff only";
auth_basic_user_file $document_root/.htpasswd;
include /etc/nginx/php-fpm.conf;
}
include /etc/nginx/php-fpm.conf;
location / {
#try_files $uri $uri/ /index.php?$args;
try_files $cachefile $uri $uri/ /index.php?$args;
}
location = /xmlrpc.php {
deny all;
}
location ~ /\.ht {
deny all;
}
}
/etc/nginx/wp-supercache.conf;
set $cache_uri $request_uri;
# Don`t cache POST requests.
if ($request_method = POST) {
set $cache_uri 'null cache';
}
# Don`t cache URL`s with GET-params.
#if ($query_string != "") {
# set $cache_uri 'null cache';
#}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php
|wp-.*.php|/feed/|index.php|wp-comments-popup.php
|wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml
|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged-in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+
|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Set the cache file
set $cachefile "/wp-content/cache/supercache/$http_host/$cache_uri/index.html";
if ($https ~* "on") {
set $cachefile "/wp-content/cache/supercache/$http_host/$cache_uri/index-https.html";
}
# Add cache file debug info as header
#add_header X-Cache-File $cachefile;
/etc/nginx/php-fpm.conf;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# fastcgi_param DOCUMENT_ROOT $document_root;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;