Magento – Enable persistent connections with Redis cache / sessions

cachesession

Using Redis as the backend for Magento cache and Magento sessions (through Cm_Cache_Backend_Redis and Cm_RedisSession with phpredis), what is the best performance wise with respect to the "persistent" section in local.xml?

The example configs Colin gives show no unique value for persistent. The comments say there may be bugs. The Tuning section says to enable persistent connections.

What are the pros/cons to enabling persistent connections with Redis and Magento for caching and sessions? Thanks for any details.

Best Answer

First, if you’re using PHP-FPM (or other threaded models) and the phpredis library, persistent connections are not possible.

If you’d like to use persistent connections, just use any string (magestore1) as the value for the persistent node in local.xml. As I understand it, this string has to be unique to your particular Magento installation, as multiple Magento virtual hosts on a single server would experience collisions if they shared <persistent /> values.

The pros:

  1. Faster response times across all pages; the delay in connecting to Redis is about 0.001 seconds, in my experience with phpredis.
  2. Fewer system calls for opening and closing sockets, so there’s slightly less CPU overhead.

The cons:

  1. Currently impossible with PHP-FPM and phpredis
  2. Odd issues are possibly more difficult to debug
  3. Bugs and segfaults can leave sockets open, requiring a system reboot to resolve odd connectivity failures
Related Topic