Suddenly my server crashed and I see that php5-fpm usage was the culprit and it’s consume 100% of CPU usage. Fyi, I use NGINX and WordPress on this case. I tried several thing to solve php-fpm issue like change listener into socket instead of ports. Also, I use APC as well, but it’s doesn’t works.
Until I found solution was using Varnish. Here is a quick step to install Varnish for WordPress on your server ( I use debian ):
1. Install Varnish on Debian
1 | apt-get install varnish |
2. Set up varnish
Edit /etc/default/varnish:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # # Should we start varnishd at boot? Set to "yes" to enable. START=yes # Maximum number of open files (for ulimit -n) NFILES=131072 # Maximum locked memory size (for ulimit -l) # Used for locking the shared memory log in memory. If you increase log size, # you need to increase this number as well MEMLOCK=82000 # Default varnish instance name is the local nodename. Can be overridden with # the -n switch, to have more instances on a single server. INSTANCE=$(uname -n) # Listen on port 6081, administration on localhost:6082, and forward to # one content server selected by the vcl file, based on the request. Use a 1GB # fixed-size cache file. # DAEMON_OPTS="-a :80 -T localhost:6082 -f /etc/varnish/default.vcl -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" |
At this configuration, I set that Varnish service start using port 80.
3. Setup Varnish
Edit /etc/varnish/default.vcl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | backend default { .host = "127.0.0.1"; .port = "82"; } # Drop any cookies sent to WordPress. sub vcl_recv { if (!(req.url ~ "wp-(login|admin)")) { unset req.http.cookie; } } # Drop any cookies WordPress tries to send back to the client. sub vcl_fetch { if (!(req.url ~ "wp-(login|admin)")) { unset beresp.http.set-cookie; } } |
At this example, my website running on NGINX with port 82.
Now, all you need just start NGINX and Varnish service. PHP5-FPM usage must be decrease now.