Hi

At work we're setting up a multi-layered cluster with a 1st line of 
web/proxy/cache servers (nginx+memcached) and several layers of PHP-FPM and 
Tomcat application servers. At the moment we're using memcached just to cache 
raw HTML pages, not serialized objects: upon a request nginx checks if that URL 
(key) is on memcached and then serves it, else it proxies the request to the 
appropriate app server which serves it and saves it to memcached. Pretty basic 
memcached usage.

The problem is that we can't get the PHP, Java and nginx implementations to 
work together, the PHP and Java consistent hashing algorithms don't seem to 
match. 

We're using:

- nginx: http://wiki.nginx.org/NginxHttpUpstreamConsistentHash 
- PHP: PECL:memcache http://pecl.php.net/package/memcache
- Java: spymemcached http://code.google.com/p/spymemcached/

Both the nginx and PHP implementations match, any HTML representation saved by 
PHP is retrieved by nginx from the same memcached server; but spymemcached's 
implementation seems to be different and with 2 memcached server only matches 
50% of the time, so it's a completely different algorithm and the matches are 
random. We're using the nginx patch and PECL:memcached with their default 
configuration, and as for spymemcached we've tried the NATIVE_HASH, CRC32_HASH 
and KETAMA_HASH algorithms but none of them matches nginx' and PHP's hashing.

Anybody else here is using memcached in Java and PHP and got them to work 
together? I've searched the list and this question has been raised several 
times but haven't find any definitive answer, just the obvious "different 
libraries may use different hashing implementations". We don't mind switching 
to other libraries.

Thanks in advance.

Regards

-- 
 Vicente Aguilar <bise...@bisente.com> | http://www.bisente.com

Reply via email to