M
M
marinakai2017-07-24 02:08:33
PHP
marinakai, 2017-07-24 02:08:33

How to fix server response time issue when using Nginx and PHP7.0-FPM?

Good day!
For several years, the server on Nginx (4 CPU 1GB RAM) worked without problems. But suddenly there was a problem with php-fpm because of which the sites on the server stopped working. After reinstalling the system, it was possible to raise the site's performance. But there was a problem with a long server response, and I just can’t figure out where the legs are growing from.
nginx.conf configs:

user www-data;
worker_processes auto;
pid /run/nginx.pid
events {
worker_connections 1024;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
keepalive_requests 100;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 2;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
#access_log /var/log/nginx/access.log;
access_logoff;
error_log /var/log/nginx/error.log crit;
gzip on;
gzip_disable "msie6";
gzip_variable on;
gzip_proxied any;
gzip_comp_level 6;
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;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

site config:
server {
listen 443 default_server;
server_name mysite.com;
# Path to the folder with the code
root /var/www/mysite.com/public_html;
index index.php index.html;
ssl on;
ssl_certificate /path/to/pem.pem;
ssl_certificate_key /path/to/key.pem;
location / {
autoindex off;
try_files $uri @opencart;
}
location @opencart {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/([^?]*) /index.php?route=$1 last;
}
}
location ~ \.tpl {
deny all;
}
location ~* ^.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
access_log off;
expires max;
log_not_found off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

I didn't change anything in the php configs.
htop shows that the mysql processes are using a lot of memory, but they used to do this before, but the server responded normally.
Please help me figure out what's what.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Borisovich, 2017-07-24
@Alexufo

Check access logs and block bots and search engines by ip. Probably the server is under load.

M
marinakai, 2017-07-24
@marinakai

access logs look normal. First of all, I thought about the load and deployed a similar system on another server with 2GB of RAM. But the problem remained.

D
Dmitry, 2017-07-24
@backender_ru

I had a similar problem with FPM, but I disabled xdebug. By the way, try running sites through the built-in PHP server: do php -S localhost:8000 in your site's DOCUMENT_ROOT and see how long the site responds from localhost. Same wget.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question