Redis

Redis

Redis is an open source, BSD licensed, advanced key-value cache and store.

Interactive Mode

Connecting on a different port which is useful if you are running things locally:

redis-cli -h 192.168.33.81 -p 6380

Set up

Web Servers - Redis:

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

yum -y install redis -y

sed -i -e 's/save 900 1/#save 900 1/' /etc/redis.conf

sed -i -e 's/save 300 10/#save 300 1/' /etc/redis.conf

sed -i -e 's/save 60 10000/#save 60 10000/' /etc/redis.conf

sed -i -e 's/# slaveof <masterip> <masterport>/slaveof 134.213.98.49 6379/' /etc/redis.conf

sed -i -e 's/# unixsocket \/tmp\/redis.sock/unixsocket \/var\/tmp\/redis.sock/' /etc/redis.conf

sed -i -e 's/# unixsocketperm 755/unixsocketperm 777/' /etc/redis.conf

chkconfig --level 2345 redis on

/etc/init.d/redis restart

Checklist

  1. Is Redis installed?
  2. Is Redis running?
  3. Has the Firewall port been opened up?

 

Web Servers - PHP Redis

git clone git://github.com/nicolasff/phpredis.git

cd phpredis

phpize

./configure

make

make install

echo "extension=redis.so" >> /etc/php.d/redis.ini

/etc/init.d/httpd restart

Architecture

In the set up below, we have a instance of Redis on each virtual. Cache1 acts as the Master. All writes go to the master as specified in the settings.php. Web1 has a direct connection to cache1 so that it is always reading the most up to date records when performing a warm cache and it is regenerating records if they do not exist in the Master instance.

Cache2 has a dual function; it can be a slave of cache1 or a master instance depending on what is happening within the system. For example, if drush cc all needs to be run, we can disconnect it from cache1 making it a Master. By doing this, the caches remain untouched whilst cache1 is updated. When cache1 has been updated, it can simple be reconnected to cache1 and a sync between them begins which propagates down to the web server. In theory, this means that the web server always have warm cache records.

Cache Reading

Redis Setup.graffle PDFEdit file

Module

The Drupal 7 Redis module include files are supposed to have no trace of Drupal code meaning that they will work across different versions if directly included. At the time of trying the module out, this was no longer the case. It was necessary to load the Database class which required the Drupal 7 database backport module. Also, in order to use Redis for the caching, it was necessary to use the D7 to D6 backport module.

A further change was made to the module in order to support a master / slave set up in the sense that you write to the master and read from the slave. I could not see how the current set up could support that feature. It looks like some changes are being though about in order to support things like clustering but that will come in the future.

JIRA Task

Investigate:  API-32 - Designing a failover for Memcache CLOSED

Benchmarking:  API-35 - Benchmark Redis and Memcache on Vagrant CLOSED   API-37 - Benchmark Redis and Memcache on web5/6 CLOSED

Go live:  API-40 - Redis ready to go live CLOSED

Useful Links