We have to two load balanced web servers, each running an instance of memcached; both web servers connect to a single MySQL server. We are seeing this behavior when publishing content and clearing caches:
* Publishing Content from server1: When content is updated and published on server1, it does not appear on server2. I have to execute a "Flush All Caches" > "Cache Tables" *on server2* for updates to appear on server2. The same also happens in reverse -- when content is published from server2.
Expected behavior would be that updating content on one server, reflects on all other servers.
* Running "Flush All Caches" or "Flush All Caches" > "Cache Tables" on server 1 flushes cache on server1, but not on server2 and vice versa.
Expected behavior would be that "Flush All Caches" on *one* server, flushes cache on *all* other servers defined in settings.php.
My settings.php around memcached is as follows:
include_once('./includes/cache.inc');
include_once('./sites/all/modules/contrib/memcache/memcache.inc');
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_servers'] = array(
'11.22.33.44:11211' => 'default',
'11.22.33.45:11211' => 'default',
);
$conf['memcache_bins'] = array('cache' => 'default');
$conf['memcache_options'] = array(
Memcached::OPT_COMPRESSION => TRUE,
Memcached::OPT_BINARY_PROTOCOL => TRUE,
);
$conf['memcache_persistent'] = TRUE;
$conf['memcache_key_prefix'] = $_SERVER['SERVER_NAME'];
Other interesting things of note:
* when I run drush vget memcache_servers, I get a No matching variable found., but I see hits to the memcache server.
* http://host/admin/reports/memcache -- shows stats for "localhost:11211" instead of showing stats for both servers defined in settings.php.
* Drupal 7.9, memcached version : 1.4.10; memcached php extension: 1.0.0.
Anyone else seeing this? How might one go about resolving this?
Comments
Comment #1
markpavlitski commentedHi kmasood,
The memcached service doesn't support replication natively and this isn't a feature currently provided by the module.
repcached is a patched memcached service which supports replication, but I don't know if this is compatible with the memcached module.
In the meantime you could either run a single memcached instance from one of your servers or you could investigate an alternative such as Redis which I believe does support this feature.
I would also suggest looking at http://shiflett.org/blog/2006/mar/server-name-versus-http-host for why it's bad to rely on $_SERVER['SERVER_NAME'].
Kind regards,
Mark
Comment #2
kmasood commentedThanks for dropping in Mark.
I wasn't looking for replication. I was trying to troubleshoot why the two servers defined by "$conf['memcache_servers']" were seemingly out of synch. With some tweaking (around SERVER_NAME of all things) we're able to get things to work.
Also, thank you for pointing out the issue with using SERVER_NAME; it continues to work rather well as a key-prefix.
Thanks again.
Comment #3
erikwebb commentedCan you give us the rest of your settings.php? (passwords removed)
I would guess that the $conf array is being reset somehow.
Comment #4
erikwebb commentedComment #5
markpavlitski commented@kmasood It sounds like you resolved the issue, but feel free to re-open this ticket if not.
Comment #6
markpavlitski commentedComment #7.0
(not verified) commentedadded syntax highlighting