Memcache acceleration for node views (advanced topic)
Introduction
When a node is viewed, radioactivity decay profiles are examined to determine whether energy should be added to the node. When this is the case, database updates are performed. This can result in up to N insert-or-updates, where N is the number of decay profiles. This process has the following side effects, which may be bad for busy sites:
- Anonymous page views can produce unexpected amounts of traffic in SQL replication logs.
- SQL queries on table
radioactivityare not likely to take advantage of query caching.
When Memcache-acceleration is enabled, these energy updates are stored into memcache daemon and processed in cron runs, thus reducing the amount of database updates performed per node view. Additionally, when cron is executed, the energy updates are combined per node and energy profile. This can reduce drastically the total number of database updates required, as typically most requests concentrate on a relatively small set of pages. Consider 10000 requests on 200 nodes between cron runs, with 3 decay profiles configured. Without memcache acceleration 30000 database modifications for energies are performed. With acceleration, 600 modifications suffice.
Configuration
Set up memcache
Radioactivity uses bin radioactivity to store the deferred energy updates. This bin should be stored to a memcached server which has relatively low frequency of flushes, i.e., not caches! Ideally, this bin would be stored in a dedicated memcached server. However, storing this bin into same server with session bin would probably be fine.
Simplistic configuration in settings.php:
$conf = array(
'cache_inc' => '/projects/drupal-contrib/drupal-5.15/sites/all/modules/memcache/memcache.inc',
'memcache_servers' => array('localhost:11211' => 'default', 'localhost:11212' => 'radioactivity'),
'memcache_bins' => array('cache' => 'default', 'radioactivity' => 'radioactivity'),
);Configure radioactivity
Visit admin/settings/radioactivity, set Memcached entry expiration time to at least twice your cron interval. Don't set it to insane numbers, as this can pollute your memcache with stale entries. Note that short cron interval, such as anything below 5 minutes, is probably a good idea. Finally, enable memcache acceleration and enjoy!
