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.

2 Answers 2


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
  • We're using mod_php with Apache pre-fork, so it should be fine with persistent connections. I'll watch the redis log to see if anything odd pops up. Commented Aug 4, 2013 at 4:08
  • 1
    @RobMangiafico be sure to watch other logs—like from Apache, Magento, and PHP—as exceptions from Magento-to-Redis integration can bubble up in odd ways. Good luck! :)
    – parhamr
    Commented Aug 7, 2013 at 21:17

One important note: If you are running Magento and Redis on the same server, it would be better to run Redis through a UNIX socket, instead of TCP/IP connection, and configure Magento to connect through that UNIX socket as well. When doing this, the <persistent> flag needs to be off (0). Persistent connections are not available when accessing Redis through a socket.

  • Hi @jissereitsma, and to enable Redis on more Magento installations on same server? How we can differentiate magento caches in case of unix sockets?
    – Simbus82
    Commented Sep 2, 2015 at 15:31
  • 1
    @simbus82 simply use same socket but specify different Redis database like you would with regular Redis TCP/IP setup. Commented Sep 2, 2015 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.