WordPress + W3 Total Cache + Redis

WordPress + W3 Total Cacheで使っていたCache MethodをMemcachedからRedisに変更しました。
W3 Total Cache変更履歴を見るとバージョン0.9.5からRedisサポートが追加されています。随分前からサポートされていたのに気付いてなかったのね...(笑)

Redisを使うためにはsshでログインしてから、yumコマンドを使って(EPELリポジトリから)Redisをインストールします。既にEPELリポジトリが有効になっていればコマンド一発でOKです。phpからredisにアクセスするにはphp-pecl-redisも必要なので一緒にインストールする必要があります。

# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
# WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

そのまま起動すると、上記のWARNINGがログファイル(/var/log/redis/redis.log)に出力されます。Redis と php-pecl-redis のインストールメモ(CentOS7.1.1503)を参考にしてWARNINGが出ないようにします。

あとはnginxとphp-fpmをreloadして、W3 Total CacheのGeneral SettingsからObject Cacheの設定をMemcachedからPage Cache、Minify、Database Cache、Object CacheのCache MethodをRedisに変更しておしまい。

スピードはほとんど変わりませんが、メモリの使用量が少し減りました。

メモリの使用量は70%台から50%台になりました。さくらのVPS(1GB)サーバなので、メモリは潤沢には使えず...。それでも月額972円払っているのよね。