Need for Speed – PHP using a Redis Server

Today was about optimizing my LAMP stack here because as you know, speed can only be replaced by more speed. Last time I was moving my MySQL server to a different machine, but I was certain that there’s more to be done for the ultimate speed gain. In this case it was luck discovering some more options.

Just for experimenting I found out a massive speed gain by installing and using a redis Server for PHP session handling. You might assume – just like me – that the redis server would make things more slow, but instead the speed gain was immense. Maybe because the redis server is running on localhost.

But how to implement? First of all you need the redis extension for php. This is a pecl module you’d need to load. Then fire up an editor and alter your php.ini file changing the session handling:

session.save_handler = redis
session.save_path = “tcp://”

Restarting the webserver put it all in place. Finally you can watch the redis server doing its job by monitoring it via CLI:

redis-cli monitor


Leave a Reply

Your email address will not be published. Required fields are marked *