Медленно работает php-fpm+nginx

hasvanbinsun

Проверенные
Сообщения
407
Реакции
75
Баллы
5,530
Как можно изменить настройки для ускорения работы.

user www-data;

worker_processes 4;

pid /run/nginx.pid;



events {

worker_connections 1024;

# multi_accept on;

use epoll;

}



http {



##

# Basic Settings

##

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 60;

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;

fastcgi_cache_path /var/cache/fpm levels=1:2 keys_zone=fcgi:100m;

fastcgi_cache_key "$scheme$request_method$host$request_uri";

##

# SSL Settings

##



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

#ssl_prefer_server_ciphers on;



##

# Logging Settings

##



access_log off;

error_log /var/log/nginx/error.log;



##

# Gzip Settings

##



gzip on;

gzip_disable "msie6";



gzip_vary on;

gzip_proxied any;

gzip_comp_level 5;

gzip_buffers 16 8k;

gzip_static off;

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=2000s;

open_file_cache_valid 3000s;

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/*;

}





#mail {

# # See sample authentication script at:

# #

#

# # auth_http localhost/auth.php;

# # pop3_capabilities "TOP" "USER";

# # imap_capabilities "IMAP4rev1" "UIDPLUS";

#

# server {

# listen localhost:110;

# protocol pop3;

# proxy on;

# }

#

# server {

# listen localhost:143;

# protocol imap;

# proxy on;

# }

#}

; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php5-fpm.sock

; Set listen(2) backlog.
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 65535

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2:-). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; priority = -19

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 30

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 4

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 2

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 8

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
;
;
;
;
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
;
;
;
;
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The access log file
; Default: not set
;access.log = log/$pool.access.log

; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)

; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
#

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 256M
max_allowed_packet = 32M
thread_stack = 2048K
thread_cache_size = 32
sort_buffer_size =2048K
net_buffer_length =8K
read_buffer_size =2048K
read_rnd_buffer_size =4096K
myisam_sort_buffer_size =8M
expire_logs_days = 4
max_binlog_size = 64M
tmp_table_size = 48M
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 128M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_buffer_pool_size = 750M
log_error = /var/log/mysql/mysql-error.log
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 32M
query_cache_size = 64M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
#
#
#
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server_tokens off;
server {
listen 127.0.0.1:8888 default_server;
#listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name localhost;

location / {
try_files $uri $uri/ /index.php?$uri&$args;
index index index.php index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}


location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.:-)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache fcgi;
fastcgi_cache_valid 200 1200m;
}

location /pma/ {
alias /usr/share/phpmyadmin/;
disable_symlinks off;
}
location ~* \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$ {
log_not_found off;
expires 7d;
}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
 
А что за тазик и в чем заключается "медленность"?
Где виртхост с форумом?

VDS Ubuntu server 14.04 2x2.0 4gb RAM. Скрипты работают быстро. Время в дэбаге на главной 0.1 сек, на остальных 0.05. Медленно загружается страница. Вирт. хостов нет. Localhost. Ещё nginx медленно отвечает на запросы.
 
Последнее редактирование:
Ещё nginx медленно отвечает на запросы.
Можно пациента в личку? Что бы говорить, что nginx медленно отдает контент, нужно взять отдельно картинку (желательно большую) и посмотреть на скорость ее загрузки; php nginx отдает php-fpm, тут он уже не при делах.

Вирт. хостов нет. Localhost.
Тогда рекомендую добавить локейшн, закрываем служебные каталоги
Код:
location ~ /(internal_data|library) {
         internal;
    }
И перед локейшеном location ~ \.php$ добавить такой ага, есть, то я выше прозевал в конфиге.
Код:
location / {
        try_files $uri $uri/ /index.php?$uri&$args;
    }
 
Последнее редактирование:
Дебаг лог покажите, мб дополнения какие тормозят
Не похоже
Время в дэбаге на главной 0.1 сек, на остальных 0.05. Медленно загружается страница.
А вот сторонние скрипты на странице очень даже могут быть, но без пациента это гадание на кофейной гуще.
 
Пациента не могу дать. Сторонних скриптов нет, только что проверил код, всё чисто. Локейшн добавил.

Page Time: 0.3177s
Memory: 5.9409 MB (Peak: 6.6118 MB)
Queries (21, time: 0.0736s, 23.2%)

  1. SELECT session_data
    FROM xf_session
    WHERE session_id = ?
    AND expiry_date >= ?
    Params: 1621ba5c1491f91507d1700a9b5d324b, 1424953771
    Run Time: 0.000579
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_session system PRIMARY,expiry_date 1
  2. SELECT user.*
    ,
    user_profile.*,
    user_option.*,
    user_privacy.*,
    permission_combination.cache_value AS global_permission_cache
    FROM xf_user AS user

    LEFT JOIN xf_user_profile AS user_profile ON
    (user_profile.user_id = user.user_id)
    LEFT JOIN xf_user_option AS user_option ON
    (user_option.user_id = user.user_id)
    LEFT JOIN xf_user_privacy AS user_privacy ON
    (user_privacy.user_id = user.user_id)
    LEFT JOIN xf_permission_combination AS permission_combination ON
    (permission_combination.permission_combination_id = user.permission_combination_id)
    WHERE user.user_id = ?
    Params: 2070
    Run Time: 0.001077
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE user const PRIMARY PRIMARY 4 const 1
    SIMPLE user_profile const PRIMARY PRIMARY 4 const 1
    SIMPLE user_option const PRIMARY PRIMARY 4 const 1
    SIMPLE user_privacy const PRIMARY PRIMARY 4 const 1
    SIMPLE permission_combination const PRIMARY PRIMARY 4 const 1
  3. SELECT profile_post.*
    ,
    posting_user.*,
    IF(posting_user.username IS NULL, profile_post.username, posting_user.username) AS username,
    receiving_user.username
    AS profile_username,
    receiving_user.gender
    AS profile_gender,
    receiving_user.user_state
    AS profile_user_state,
    receiving_user.user_group_id
    AS profile_user_group_id,
    receiving_user.secondary_group_ids
    AS profile_secondary_group_ids,
    receiving_user.display_style_group_id
    AS profile_display_style_group_id,
    receiving_user.is_banned
    AS profile_is_banned,
    receiving_user.is_admin
    AS profile_is_admin,
    receiving_user.is_moderator
    AS profile_is_moderator,
    receiving_user.avatar_date
    AS profile_avatar_date,
    receiving_user.gravatar
    AS profile_gravatar,
    receiving_user.warning_points
    AS profile_warning_points,
    receiving_user.permission_combination_id
    AS profile_permission_combination_id,
    receiving_user_privacy.allow_view_profile
    AS profile_allow_view_profile,
    receiving_user_privacy.allow_post_profile
    AS profile_allow_post_profile,
    receiving_user_privacy.allow_send_personal_conversation
    AS profile_allow_send_personal_conversation,
    receiving_user_privacy.allow_view_identities
    AS profile_allow_view_identities,
    receiving_user_privacy.allow_receive_news_feed
    AS profile_allow_allow_receive_news_feed,
    IF (receiving_user_follow.follow_user_id, 1, 0)
    AS following_2070
    FROM xf_profile_post AS profile_post

    LEFT JOIN xf_user AS posting_user ON
    (posting_user.user_id = profile_post.user_id)
    LEFT JOIN xf_user AS receiving_user ON
    (receiving_user.user_id = profile_post.profile_user_id)
    LEFT JOIN xf_user_privacy AS receiving_user_privacy ON
    (receiving_user_privacy.user_id = profile_post.profile_user_id)
    LEFT JOIN xf_user_follow AS receiving_user_follow ON
    (receiving_user_follow.user_id = profile_post.profile_user_id AND follow_user_id = 2070)
    WHERE (profile_post.message_state IN ('visible'))
    ORDER BY profile_post.post_date DESC
    LIMIT 20
    Run Time: 0.000943
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE profile_post ALL 672 Using where; Using filesort
    SIMPLE posting_user eq_ref PRIMARY PRIMARY 4 forumsbd.profile_post.user_id 1
    SIMPLE receiving_user eq_ref PRIMARY PRIMARY 4 forumsbd.profile_post.profile_user_id 1
    SIMPLE receiving_user_privacy eq_ref PRIMARY PRIMARY 4 forumsbd.profile_post.profile_user_id 1
    SIMPLE receiving_user_follow eq_ref PRIMARY,follow_user_id PRIMARY 8 forumsbd.profile_post.profile_user_id,const 1 Using index
  4. SELECT *
    FROM xf_node
    WHERE display_in_list = 1
    ORDER BY lft ASC
    Run Time: 0.000640
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_node ALL display_in_list 44 Using where; Using filesort
  5. SELECT content_id, cache_value
    FROM xf_permission_cache_content
    WHERE permission_combination_id = ?
    AND content_type = 'node'
    Params: 2
    Run Time: 0.000544
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_permission_cache_content ref PRIMARY PRIMARY 31 const,const 43 Using where
  6. SELECT forum.*
    ,
    IF(forum_read.forum_read_date > 1422361771, forum_read.forum_read_date, 1422361771) AS forum_read_date
    FROM xf_forum AS forum
    INNER JOIN xf_node AS node ON (node.node_id = forum.node_id)

    LEFT JOIN xf_forum_read AS forum_read ON
    (forum_read.node_id = forum.node_id
    AND forum_read.user_id = 2070)
    WHERE forum.node_id IN (2, 15, 16, 20, 38, 39, 40, 43, 37, 52, 53, 7, 9, 32, 28, 44, 23, 51, 45, 49, 18, 19, 25, 26, 27, 31, 50, 21, 29, 34, 47, 48, 24, 13, 14)
    Run Time: 0.001815
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE forum ALL PRIMARY 37 Using where
    SIMPLE forum_read eq_ref user_id_node_id,node_id user_id_node_id 8 const,forumsbd.forum.node_id 1
    SIMPLE node eq_ref PRIMARY PRIMARY 4 forumsbd.forum.node_id 1 Using index
  7. SELECT user_id, avatar_date, gravatar, gender
    FROM xf_user AS user
    WHERE user.user_id IN (1, 144, 3037, 2535, 4789, 2070, 182, 1816, 4, 4776, 4769, 4792, 940, 3735, 7, 4203, 2089)
    Run Time: 0.000615
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE user range PRIMARY PRIMARY 4 17 Using where
  8. SELECT user.user_id, user.display_style_group_id
    FROM xf_user AS user
    WHERE user.user_id IN (1, 144, 3037, 2535, 4789, 2070, 182, 1816, 4, 4776, 4769, 4792, 0, 940, 3735, 7, 4203, 2089)
    Run Time: 0.000354
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE user range PRIMARY PRIMARY 4 18 Using where
  9. SELECT session_activity.*
    ,
    user.*
    FROM xf_session_activity AS session_activity

    LEFT JOIN xf_user AS user ON
    (user.user_id = session_activity.user_id)
    WHERE (session_activity.view_date > 1424950171)
    ORDER BY session_activity.view_date DESC
    Run Time: 0.000973
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE session_activity system view_date 1
    SIMPLE user const PRIMARY PRIMARY 4 const 1
  10. SELECT thread_id, title, user_id, username, post_date, discussion_state FROM xf_thread as thread WHERE NOT ISNULL(thread.thread_id) AND thread.discussion_state = 'visible' ORDER BY post_date DESC LIMIT 10
    Run Time: 0.000799
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE thread ALL PRIMARY 710 Using where; Using filesort
  11. SELECT user.*

    FROM xf_user AS user

    WHERE user.user_id IN (144, 4792, 725, 4769, 144, 144, 144, 144, 3248, 1)
    ORDER BY user.username
    Run Time: 0.000738
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE user range PRIMARY PRIMARY 4 6 Using where; Using filesort
  12. UPDATE `xf_session` SET `expiry_date` = ? WHERE (session_id = '1621ba5c1491f91507d1700a9b5d324b')
    Params: 1424957371
    Run Time: 0.000635
  13. INSERT INTO xf_session_activity
    (user_id, unique_key, ip, controller_name, controller_action, view_state, params, view_date, robot_key)
    VALUES
    (?, ?, ?, ?, ?, ?, ?, ?, ?)
    ON DUPLICATE KEY UPDATE
    ip = VALUES(ip),
    controller_name = VALUES(controller_name),
    controller_action = VALUES(controller_action),
    view_state = VALUES(view_state),
    params = VALUES(params),
    view_date = VALUES(view_date),
    robot_key = VALUES(robot_key)
    Params: 2070, 2070, , XenForo_ControllerPublic_Forum, Index, valid, node_name=, 1424953771,
    Run Time: 0.000415
  14. SELECT title, template_compiled
    FROM xf_template_compiled
    WHERE title IN ('page_nav', 'node_forum_level_2', 'node_forum_level_n', 'node_category_level_1', 'forum_list_who_visited_wrapper', 'forum_list', 'dark_taigachat_links', 'VietXfAdvStats_wrapper', 'dark_taigachat', 'dark_taigachat_list', 'threadrating_rate', 'PAGE_CONTAINER')
    AND style_id = ?
    AND language_id = ?
    Params: 1, 2
    Run Time: 0.001894
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_template_compiled range PRIMARY PRIMARY 60 12 Using where
  15. replace into dark_taigachat_activity
    set user_id = ?, date = UNIX_TIMESTAMP()
    Params: 2070
    Run Time: 0.000338
  16. SELECT user.*

    FROM xf_user AS user

    WHERE user.user_state = 'valid' AND user.is_banned = 0
    ORDER BY user.register_date DESC
    LIMIT 10
    Run Time: 0.000714
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE user index user_state register_date 4 10 Using where
  17. SELECT *
    FROM xf_node

    ORDER BY lft ASC
    Run Time: 0.000956
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_node ALL 44 Using filesort
  18. SELECT content_id, cache_value
    FROM xf_permission_cache_content
    WHERE permission_combination_id = ?
    AND content_type = 'node'
    Params: 2
    Run Time: 0.001034
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_permission_cache_content ref PRIMARY PRIMARY 31 const,const 43 Using where
  19. SELECT thread.*
    ,
    GREATEST(COALESCE(thread_read.thread_read_date, 0), COALESCE(forum_read.forum_read_date, 0), 1422361771) AS thread_read_date,
    node.node_id AS forum_id, node.title AS forum_title,
    user.*,
    user_rue.display_style_group_id AS last_post_display_style_group_id
    FROM xf_thread AS thread

    LEFT JOIN xf_thread_read AS thread_read ON
    (thread_read.thread_id = thread.thread_id
    AND thread_read.user_id = 2070)
    LEFT JOIN xf_forum_read AS forum_read ON
    (forum_read.node_id = thread.node_id
    AND forum_read.user_id = 2070)
    INNER JOIN xf_node AS node ON
    (node.node_id = thread.node_id)
    INNER JOIN xf_forum AS forum ON
    (forum.node_id = thread.node_id)
    LEFT JOIN xf_user AS user ON
    (user.user_id = thread.last_post_user_id)
    LEFT JOIN xf_user AS user_rue ON
    (user_rue.user_id = thread.last_post_user_id)
    WHERE (1=1) AND (thread.node_id IN ('1', '2', '15', '16', '20', '38', '39', '40', '35', '43', '37', '41', '52', '53', '3', '7', '9', '32', '28', '44', '23', '51', '45', '17', '49', '18', '19', '25', '26', '27', '31', '50', '21', '29', '34', '46', '47', '48', '12', '24', '13', '14')) AND ((thread.discussion_type != 'redirect' AND thread.discussion_state != 'deleted' AND thread.discussion_state != 'moderated'))
    ORDER BY thread.last_post_date DESC
    LIMIT 10
    Run Time: 0.057677
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE forum index PRIMARY PRIMARY 4 37 Using where; Using index; Using temporary; Using filesort
    SIMPLE thread ref node_id_last_post_date,node_id_sticky_state_last_post node_id_last_post_date 4 forumsbd.forum.node_id 9 Using where
    SIMPLE thread_read eq_ref user_id_thread_id,thread_id user_id_thread_id 8 const,forumsbd.thread.thread_id 1
    SIMPLE forum_read eq_ref user_id_node_id,node_id user_id_node_id 8 const,forumsbd.thread.node_id 1
    SIMPLE node eq_ref PRIMARY PRIMARY 4 forumsbd.thread.node_id 1 Using where
    SIMPLE user eq_ref PRIMARY PRIMARY 4 forumsbd.thread.last_post_user_id 1
    SIMPLE user_rue eq_ref PRIMARY PRIMARY 4 forumsbd.thread.last_post_user_id 1
  20. SELECT title, phrase_text
    FROM xf_phrase_compiled
    WHERE language_id = ?
    AND title IN ('VietXfAdvStats_section_users_new', 'VietXfAdvStats_section_users_top_posters', 'VietXfAdvStats_section_users_top_trophy_points', 'VietXfAdvStats_section_users_top_liked', 'VietXfAdvStats_section_threads_recent', 'VietXfAdvStats_section_threads_latest', 'VietXfAdvStats_section_threads_hot')
    Params: 2
    Run Time: 0.000308
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_phrase_compiled range PRIMARY PRIMARY 106 7 Using where
  21. SELECT title, template_compiled
    FROM xf_template_compiled
    WHERE title IN ('VietxfAdvStats_users_new', 'VietXfAdvStats_users', 'VietxfAdvStats_threads_recent', 'VietXfAdvStats_threads')
    AND style_id = ?
    AND language_id = ?
    Params: 1, 2
    Run Time: 0.000528
    Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
    SIMPLE xf_template_compiled range PRIMARY PRIMARY 60 4 Using where
Included Files (143, XenForo Classes: 64)
  1. index.php
  2. library\XenForo\Autoloader.php
  3. library\XenForo\Application.php
  4. library\Zend\Registry.php
  5. library\Lgpl\utf8.php
  6. library\Zend\Config.php
  7. library\config.php
  8. library\XenForo\FrontController.php
  9. library\XenForo\Dependencies\Public.php
  10. library\XenForo\Dependencies\Abstract.php
  11. library\Zend\Controller\Request\Http.php
  12. library\Zend\Controller\Request\Abstract.php
  13. library\Zend\Uri.php
  14. library\Zend\Controller\Response\Http.php
  15. library\Zend\Controller\Response\Abstract.php
  16. library\XenForo\Model\DataRegistry.php
  17. library\XenForo\Model.php
  18. library\Zend\Cache.php
  19. library\Zend\Cache\Backend\Xcache.php
  20. library\Zend\Cache\Backend\Interface.php
  21. library\Zend\Cache\Backend.php
  22. library\Zend\Cache\Core.php
  23. library\XenForo\CodeEvent.php
  24. library\XenForo\Options.php
  25. library\XenForo\Link.php
  26. library\XenForo\Template\Helper\Core.php
  27. library\Waindigo\Listener\InitDependencies.php
  28. library\Waindigo\Listener\InitDependencies\20140612.php
  29. library\Waindigo\Listener\ControllerPreDispatch\20140603.php
  30. library\XenForo\Router.php
  31. library\XenForo\Route\Filter.php
  32. library\XenForo\Route\Interface.php
  33. library\XenForo\Route\ResponseSuffix.php
  34. library\XenForo\Route\Prefix.php
  35. library\XenForo\Route\Prefix\Index.php
  36. library\XenForo\RouteMatch.php
  37. library\XenForo\ControllerPublic\Index.php
  38. library\XenForo\ControllerPublic\Abstract.php
  39. library\XenForo\Controller.php
  40. library\LatestThread\Listener\Listener.php
  41. library\bdReputation\Listener.php
  42. library\ThreadRating\Listener\Class.php
  43. library\Icewind\ForumThreadViews\Listener\LoadClassController.php
  44. library\ConversationPost\Listener.php
  45. library\Vinavb\CustomNodeIcon\Listener.php
  46. library\XenForo\Input.php
  47. library\XenForo\Session.php
  48. library\Zend\Db.php
  49. library\Zend\Db\Adapter\Mysqli.php
  50. library\Zend\Db\Adapter\Abstract.php
  51. library\Zend\Db\Select.php
  52. library\Zend\Db\Expr.php
  53. library\Zend\Db\Profiler.php
  54. library\Zend\Db\Statement\Mysqli.php
  55. library\Zend\Db\Statement.php
  56. library\Zend\Db\Statement\Interface.php
  57. library\XenForo\Helper\Ip.php
  58. library\Zend\Db\Profiler\Query.php
  59. library\XenForo\Visitor.php
  60. library\XenForo\Model\User.php
  61. library\VietXfAdvStats\Listener.php
  62. library\RichUsernameEverywhere\Listener.php
  63. library\Dark\TaigaChat\EventListener\Listener.php
  64. library\VietXfAdvStats\XenForo\Model\User.php
  65. library\XenForo\Permission.php
  66. library\XenForo\Phrase.php
  67. library\XenForo\Locale.php
  68. library\UnreadPostCount\Listener.php
  69. library\UnreadPostCount\Model\Unread.php
  70. library\Waindigo\Listener\Template\20140612.php
  71. library\Waindigo\Listener\TemplateHook\20130522.php
  72. library\Waindigo\Listener\TemplatePostRender\20130522.php
  73. library\Waindigo\Listener\TemplateCreate\20130522.php
  74. library\XenForo\ControllerResponse\ReroutePath.php
  75. library\XenForo\ControllerResponse\Abstract.php
  76. library\XenForo\Route\Prefix\Forums.php
  77. library\XenForo\ControllerPublic\Forum.php
  78. library\Waindigo\LastPostAvatar\Listener\LoadClass.php
  79. library\Waindigo\Listener\LoadClass.php
  80. library\Waindigo\Listener\LoadClass\20140604.php
  81. library\Andy\SimilarThreads\Listener.php
  82. library\Waindigo\LastPostAvatar\Extend\XenForo\ControllerPublic\Forum.php
  83. library\LatestThread\Controller\Public.php
  84. library\ThreadRating\ControllerPublic\Forum.php
  85. library\Icewind\ForumThreadViews\ControllerPublic\Forum.php
  86. library\UnreadPostCount\ControllerPublic\Forum.php
  87. library\Andy\SimilarThreads\ControllerPublic\Forum.php
  88. library\XenForo\Model\ProfilePost.php
  89. library\XenForo\Model\UserProfile.php
  90. library\XenForo\Model\Node.php
  91. library\Waindigo\LastPostAvatar\Extend\XenForo\Model\Node.php
  92. library\RichUsernameEverywhere\Node.php
  93. library\XenForo\NodeHandler\Category.php
  94. library\XenForo\NodeHandler\Abstract.php
  95. library\XenForo\NodeHandler\Forum.php
  96. library\XenForo\Model\Category.php
  97. library\XenForo\Model\Forum.php
  98. library\XenForo\Helper\String.php
  99. library\XenForo\Model\Session.php
  100. library\Dark\TaigaChat\Model\SessionOverride.php
  101. library\XenForo\ControllerResponse\View.php
  102. library\LatestThread\Model\TLatestThread.php
  103. library\XenForo\Route\Prefix\Threads.php
  104. library\Icewind\ForumThreadViews\Model\Views.php
  105. library\XenForo\ViewRenderer\HtmlPublic.php
  106. library\XenForo\ViewRenderer\Abstract.php
  107. library\XenForo\Template\Public.php
  108. library\XenForo\Template\Abstract.php
  109. library\XenForo\ViewPublic\Forum\List.php
  110. library\XenForo\ViewPublic\Base.php
  111. library\XenForo\View.php
  112. library\QuickReplyInsertUsername\Listener\LoadClass.php
  113. library\XenForo\ViewPublic\Helper\Node.php
  114. library\VietXfAdvStats\Model\GetUserGroup.php
  115. library\Sedo\GoToTop\Listener\Templates.php
  116. library\WhoHasVisited\Listener.php
  117. library\XenForo\Route\Prefix\Members.php
  118. library\Dark\TaigaChat\EventListener\NavigationTabs.php
  119. library\ThreadRating\Listener\Template.php
  120. library\QuickReplyInsertUsername\Listener\Template.php
  121. library\CemZoo\EasyBan\Template\Hook.php
  122. library\Dark\TaigaChat\Model\TaigaChat.php
  123. library\Dark\TaigaChat\Helper\Global.php
  124. library\XenForo\Route\Prefix\Categories.php
  125. library\XenForo\Model\Avatar.php
  126. library\XenForo\Route\Prefix\Posts.php
  127. library\VietXfAdvStats\Option.php
  128. library\XenForo\Route\Prefix\ProfilePosts.php
  129. library\WhoHasVisited\Model\WhoVisited.php
  130. library\XenForo\Helper\Criteria.php
  131. library\XenForo\Debug.php
  132. library\UnreadPostCount\Callback.php
  133. library\XenForo\ViewRenderer\Json.php
  134. library\VietXfAdvStats\Renderer.php
  135. library\XenForo\NodeHandler\LinkForum.php
  136. library\XenForo\Model\LinkForum.php
  137. library\XenForo\Model\Thread.php
  138. library\Waindigo\LastPostAvatar\Extend\XenForo\Model\Thread.php
  139. library\VietXfAdvStats\XenForo\Model\Thread.php
  140. library\RichUsernameEverywhere\Thread.php
  141. library\ThreadRating\Model\Thread.php
  142. library\UnreadPostCount\Model\Thread.php
  143. library\Vinavb\CustomNodeIcon\Icon.php
 
hasvanbinsun, смотри логи nginx, особенно error.log, есть что там интересное. Дебаг в принципе сносный и это не похоже на php.
Добавь в конфиг nginx, в секцию http
resolver 8.8.8.8
и убери open_file_cache* - кеш дескрипторов удобней писать в локейш со статикой, если есть такая необходимость.
 
Последнее редактирование:
hasvanbinsun, смотри логи nginx, особенно error.log, есть что там интересное. Дебаг в принципе сносный и это не похоже на php
Добавь в конфиг nginx, в секцию http
resolver 8.8.8.8

Добавил, результата не дало.
events.mechanism закоменчен был, поставил epoll
process.priority = -5 вот что добавил в php, стал работать чуть чуть быстрее.
 
wget -p страницу за сколько скачивает? Желательно с другого компа.
не могу сказать, все работает на локалхосте. Долго грузятся изображения.

Вообщем кто знает, как оптимизировать конфинурацию, подкиньте идей, буду очень благодарен.
 
Общая оценка PageSpeed для страницы XXX составляет 87(из 100)
Это не важно, время ответа сервера каково? Вторая ссылка более удобная для детальной диагностики, обратить внимание на отдачу статического контента. Посмотреть top/iotop на сервере.

После авторизации оценка составляет 78(из 100), нормально?
В гугле есть расшифровка каждого критерия оценки, если скорость отдачи низкая - гугл будет ругаться на это.
 
Последнее редактирование:
Это не важно, время ответа сервера каково? Вторая ссылка более удобная для детальной диагностики, обратить внимание на отдачу статического контента. Посмотреть top/iotop на сервере.


В гугле есть расшифровка каждого критерия оценки, если скорость отдачи низкая - гугл будет ругаться на это.

Страница весит около 1mb. Время загрузки 2.5 сек. Сейчас буду переходить на gzip_ststic для схатия всех информации
 
Mongo key-value, при чем тут она и форум не очень понимаю.

По поводу MariaDB - да, проекты похожи по производительности, но в целом по характеристикам последняя перкона лучше. С учетом особенно того, что, как уже написал выше, XF целиком на InnoDB, который именно в перконе оптимизирован лучше всего (заменой на XtraDB). Вот полезная статья по теме:
 
Mongo key-value, при чем тут она и форум не очень понимаю.

По поводу MariaDB - да, проекты похожи по производительности, но в целом по характеристикам последняя перкона лучше. С учетом особенно того, что, как уже написал выше, XF целиком на InnoDB, который именно в перконе оптимизирован лучше всего (заменой на XtraDB). Вот полезная статья по теме:

Спасибо, почитаю, попробую пошаманить. Давно хотел слезть с мускула, как я понял в моей ситуации форум тормозит именно из за БД, а не вебсервера.
 
hasvanbinsun, ну так легко проверить. Включи отладку, нажми на время генерации страницы снизу - откроется окно. Там будет что-то вроде этого:
Код:
Page Time: 0.2834s
Memory: 6.7345 MB (Peak: 9.4302 MB)
Queries (14, time: 0.0155s, 5.5%)
Т.е. даже в процентах видно, сколько mysql потребляет от времени на генерацию страницы.
 
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу