Configuration of Redis for Drupal 6

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
superfedya's picture

Hi,

Right now I use http://drupal.org/project/cache_backport + http://drupal.org/project/redis

In my settings.php I put:

  $conf['cache_inc'] = 'sites/all/modules/cache_backport/cache.inc';
  $conf['redis_client_interface']      = 'PhpRedis';
  $conf['cache_backends'][]            = 'sites/all/modules/redis/redis.autoload.inc';
  $conf['cache_default_class'] = 'Redis_Cache';
  $conf['cache_prefix'] = 'prt_';

It is OK? Or I can make it better?

Thanks

Comments

Maybe there is a good cache

superfedya's picture

Maybe there is a good cache combination? Like a APC + Redis?

// Use APC for 'cache_menu'.
$conf['cache_class_cache_menu'] = 'DrupalAPCCache';

// Use Memcached for 'cache_page'.
$conf['cache_class_cache_page'] = 'Redis_Cache';

?

This is my configuration

dmouse's picture

In Drupal 6 the cache tables look like it this:

mysql> show tables like 'cache%';
+-----------------------+
| Tables_in_d6 (cache%) |
+-----------------------+
| cache                 |
| cache_block           |
| cache_content         |
| cache_filter          |
| cache_form            |
| cache_menu            |
| cache_page            |
| cache_shorten         |
| cache_update          |
| cache_views           |
| cache_views_data      |
+-----------------------+
11 rows in set (0.00 sec)

In base of count result in each table:

mysql> select count() from cache_content;
+----------+
| count(
) |
+----------+
|    43062 |
+----------+
1 row in set (0.18 sec)

mysql> select count() from cache_filter;
+----------+
| count(
) |
+----------+
|    50195 |
+----------+

mysql> select count() from cache_menu;
+----------+
| count(
) |
+----------+
|   148803 |
+----------+
1 row in set (0.00 sec)

I did this configuration

<?php
/**
* Settings.php
*/
//...
define('DRUPAL_ROOT', dirname(__FILE__));
define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/../all/libraries/predis/lib/');
$conf['cache_inc'] = 'sites/all/modules/cache_backport/cache.inc';
$conf['redis_client_interface']            = 'Predis';
$conf['cache_backends'][]                 = 'sites/all/modules/redis/redis.autoload.inc';
$conf['cache_class_cache_block']     = 'Redis_Cache';
$conf['cache_class_cache_content'] = 'Redis_Cache';
$conf['cache_class_cache_filter']      = 'Redis_Cache';
$conf['cache_class_cache_page']     = 'Redis_Cache';

//..
?>

You can show the storage

dmouse's picture

You can show the storage cache in /admin/settings/performance/cache-backend by default cache I have decided to leave the other cache with mysql.

BTW, I have using Predis look like more cool XD

regards

Missed this thread when it

Jamie Holly's picture

Missed this thread when it came out. Never knew someone tried Redis for a Drupal cache backend. That's a rather interesting idea.

For mixing caches, I usually end up using APC for the page cache and memcached for everything else (except form, keep that in database so you don't get expired form errors). You get huge performances keeping page caching on APC, since APC doesn't require a network connection and since page caching is your anonymous views, that adds up quick.

Honestly though I don't know if I would use redis for Drupal caching. The only real plus side to it is replication. There's also the persistent data factor that can be viewed as a plus, but also a negative (now adding disk i/o).

Looking at the modules though, it appears they are just doing Key/Value on Redis. Memcached will actually out perform on those (though Redis is catching up) when it comes to reads. Writes, Redis wins. Of course you are going to have far more reads than writes from the database.

Honestly though, short of doing some custom stuff in Drupal where I would need certain functionality like pub/sub or data structure store, I would probably stick with memcache. That's not to say that Redis isn't amazing, because it is. I have used it on a few larger scale Node apps and it just down right works and performs great. It's just that Memcached has been a proven winner for Drupal caching and a tool more geared towards that job.


HollyIT - Grab the Netbeans Drupal Development Tool at GitHub.