L
L
lolka022017-10-24 19:52:05
PHP
lolka02, 2017-10-24 19:52:05

Why is the site slow?

There is a site with attendance of 1700 visitors per day, on average online 18, the yii engine on the server is a bunch of nginx + php-fpm. It opens very slowly, I thought I rewrote it anyway, the speed didn’t increase much, I tried to copy the site files and run on behalf of another ssh user, another pool fpm (or as it’s called in the configs, I specify a different port,) I change the fastcgi_pass port 127.0.0.1:9001 on fastcgi_pass 127.0.0.1:9002 and run in parallel with another domain, everything works fast. Where to set up so that there is no heavy load?
here is the site pool
[site.ru]
listen = 127.0.0.1:9001
user = site
group = site
listen.owner = site
listen.mode = 770
chdir = /home/site/data/
pm = ondemand
pm.max_children = 4

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Zubkov, 2017-10-24
@zubkov_work

Turn on the debug panel in yii2 and see what is being processed slowly.

M
Mikhail Grigoriev, 2017-10-27
@Sleuthhound

listen = 127.0.0.1:9001

1. Use unix socket, this will increase the speed of the nginx + php-fpm bundle.
Example of a php-fpm pool:
[site.ru]
listen = /var/lib/php5-fpm/siteru.sock
listen.owner = site
listen.group = site
listen.mode = 0660
...

nginx setup example:
location ~ \.php$ {
  ...
  fastcgi_pass unix:/var/lib/php5-fpm/siteru.sock;
  ...
}

2. Use the dynamic model, with ondemand you most likely run into pm.max_children
An example for dynamic:
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 500

3. Enable slow query log on mysql, enable debug in yii2, enable debug logs on php-fpm
An example of enabling debug logs for php-fpm:
; Перенаправлять вывод процесса в лог
catch_workers_output = yes
; Если скрипт выполняется больше указанного времени, писать отладочную информацию в slowlog
request_slowlog_timeout = 3
; Лог-файл для медленных запросов
slowlog = /var/log/fpm-php/siteru.slow.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question