Tag Archives: session

PHP Sessions in Redis

If your php application requires sessions and it’s hosted on a scaled high available infrastructure, it’s required to have these sessions stored on a decentralised and HA platform as well, in order to avoid to rely on session persistent options on the load balancer or another Cloud Server.
Redis as a Service is a nice fit for this purpose.

Here an example using Rackspace Object Rocket http://www.rackspace.co.uk/objectrocket/redis

To achieve this it’s required to install the right package.

In Centos/RHEL, there is the IUS package available:

yum install php56u-pecl-redis

After that, the php.ini should be changed like this:

 session.save_handler = redis 
 session.save_path = "tcp://REDISOBJECTROCKETFQDN:PORT?auth=REDISPASSWORD"

To increase performance and reduce the “noise” for repetitive DNS queries (especially in case of SaaS which uses FQDN instead of an IP) it is also recommended to install nscd to cache the DNS queries.