Solved WordPress abysmal performance

10.2 here. I am trying to run Wordpress out of a jail created with iocage. Installation of Nginx, php-fpm, MySQL, and Wordpress (using pkg install) went out of glitch. Here are few configuration files. I would appreciate any help.
nginx.conf

Code:
user  www;
worker_processes  8;

error_log /var/log/error.log info;
# pid  logs/nginx.pid;


events {
  worker_connections  1024;
}


http {
  include  mime.types;
  default_type  application/octet-stream;

  #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  #  '$status $body_bytes_sent "$http_referer" '
  #  '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /var/log/access.log;

  sendfile  on;
  #tcp_nopush  on;

  keepalive_timeout  65;

  #gzip  on;

  server {
  listen  80;
  server_name  lweb.autonlab.org;

  #charset koi8-r;

  #access_log  logs/host.access.log  main;

  location / {
  #root  /usr/local/www/lweb;
  root  /usr/local/www/wordpress;
  index  index.php index.html;
  }

  #error_page  404  /404.html;

  # redirect server error pages to the static page /50x.html
  error_page  500 502 503 504  /50x.html;
  location = /50x.html {
  root  /usr/local/www/nginx-dist;
  }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
#  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/var/run/php-fpm.sock;
#  fastcgi_param  SCRIPT_FILENAME  /usr/local/www/lweb/$fastcgi_script
_name;
  fastcgi_param  SCRIPT_FILENAME  /usr/local/www/wordpress/$fastcgi_sc
ript_name;
  include  fastcgi_params;
  }
  }
}

Some modification from vanilla php-fpm.conf
Code:
events.mechanism = kqueue
listen = /var/run/php-fpm.sock
listen.owner = www
listen.group = www
listen.mode = 0660
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 80
pm.start_servers = 8
pm.min_spare_servers = 1
pm.max_spare_servers = 3

php.ini

Code:
cgi.fix_pathinfo=1

I also tried puting 0.

The performance is truly abysmal. I need to wait anywhere from 45-90 second to page to load. Running vanilla php page is OK.
 
I host a Wordpress site with nginx, php-fpm, php56, and MariaDB10 (none in a jail) on FreeBSD 10.2-RELEASE and everything is speedy.

The only thing I noticed is in your php-fpm.conf. When pm = ondemand, the settings pm.min_spare_servers, pm.max_spare_servers, and pm.start_servers are not used. You could try setting pm = dynamic and see if that changes anything.

Can you check if the database is slow?
 
  • Thanks
Reactions: Oko
Just a week ago I stumbled across a performance issue of a simple http service written in C by myself for FreeBSD and Mac OS X. I only got full speed (45 % better than apache24-mod-worker, measured by httperf) once I enabled TCP_NODELAY on the listening sockets of my http server. Without that almost each request was delayed by 100 ms.

nginx got a similar option (see https://t37.net/nginx-optimization-understanding-sendfile-tcp_nodelay-and-tcp_nopush.html). Perhaps you might want to experiment a little bit more with the various nginx settings -- perhaps disable tcp_nopush.
 
  • Thanks
Reactions: Oko
I host a Wordpress site with nginx, php-fpm, php56, and MariaDB10 (none in a jail) on FreeBSD 10.2-RELEASE and everything is speedy.

The only thing I noticed is in your php-fpm.conf. When pm = ondemand, the settings pm.min_spare_servers, pm.max_spare_servers, and pm.start_servers are not used. You could try setting pm = dynamic and see if that changes anything.

Can you check if the database is slow?
Thanks for the suggestion. I had pm = dynamic at first which is the default option but it didn't work. Turning on debug php-fpm debug mode and found pile of errors related to that option which made me switch to pm = ondemand

How would you check if MySQL is slow. That did occur to me. There is also an option in wp-confiugre.php which asks for the hostname of the database. I left there localhost. Could you please check what you have? It almost look like server is waiting for some DNS resolution.
 
Do you have a separate MySQL-jail or "all in one"?
How does you /etc/hosts look like?
What happens, if you put 127.0.0.1 into the hostname of the database?

Regards
Markus
 
I have localhost for DB_HOST in my wp-config.php. Your jail settings may require something different.

What php-fpm errors were you getting?
 
  • Thanks
Reactions: Oko
Do you have a separate MySQL-jail or "all in one"?
How does you /etc/hosts look like?
What happens, if you put 127.0.0.1 into the hostname of the database?

Regards
Markus
MySQL, php-fpm, nginx, wordpress are all in the same jail. The Wordpress can't find the database. The installation gets broken.
 
I have localhost for DB_HOST in my wp-config.php. Your jail settings may require something different.

What php-fpm errors were you getting?
Code:
[31-Aug-2015 00:58:55.355015] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:56.382277] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:57.445769] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:58.509277] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:59.572788] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:59:00.636299] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
 
[31-Aug-2015 00:58:55.355015] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:56.382277] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:57.445769] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:58.509277] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:58:59.572788] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[31-Aug-2015 00:59:00.636299] DEBUG: pid 61398, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children

I believe those are really just messages and not warnings or errors generated when log_level = debug. I normally keep my log_level = notice but I do see the same messages as you when set to debug. You could set the slowlog and request_slowlog_timeout directives to get a PHP backtrace on slow connections.

My guess is a networking issue relating to the jail. I am not very familiar with how loopback addresses work inside a jail. You also may have to set MySQL to listen to the correct IP for the jail.
 
Keep in mind that a jail does not have a lo0 and therefore no 127.0.0.1.
 
Keep in mind that a jail does not have a lo0 and therefor no 127.0.0.1.

Jails can have all addresses of the host visible including 127.0.0.1 if you really want to do so but it's of course not very secure if the goal is to separate the jail services from the host.
 
I hate when I do something stupid like this. I had for server name in my nginx.conf file lweb.autonlab.org. However DNS record and the hostname of the Jail were reading lweb.dmz.autonlab.org. Editing nginx.conf file accordingly made all the difference. Works super fast.
 
Back
Top