how to configure memcached client consistently in php and clojure?

39 views
Skip to first unread message

Joachim De Beule

unread,
Jul 10, 2013, 6:19:36 AM7/10/13
to clojure-...@googlegroups.com
Dear list,

I have a memcached cluster with 20+ servers that I need to access both from php and clojure (java). The problem is that I can't figure out how to set the hashing and locator strategies consistently in php and java.

On the php side we use crc32+consistent hashing.

On the java side, I've tried both spymemcached and xmemcached. By trial and error I found that in both cases I can get values that were set with php, provided that I find a good combination of a hashing/locator algorithm ("consistent", "php", "ketama", ...) *and* the order in which I specify servers.

For instance, with xmemcached, these might work:

(with-client (memcached "server02:11211 server04:11211 server03:11211" :hash :php)
  (get "d0b6e29b5b377ed11f84f73f50655a49"))

(with-client (memcached "server04:11211 server02:11211 server03:11211" :hash :standard)
  (get "d0b6e29b5b377ed11f84f73f50655a49"))

But these not:

(with-client (memcached "server02:11211 server04:11211 server03:11211" :hash :standard)
  (get "d0b6e29b5b377ed11f84f73f50655a49"))

(with-client (memcached "server04:11211 server02:11211 server03:11211" :hash :php)
  (get "d0b6e29b5b377ed11f84f73f50655a49"))

The problem is that I don't know how to determine the good combination/order of servers automatically. Since I am dealing with 20+ servers, trying all possibilities is not an option. Any ideas?

Thanks!
Joachim.

Michael Klishin

unread,
Jul 10, 2013, 6:26:15 AM7/10/13
to clojure-...@googlegroups.com

2013/7/10 Joachim De Beule <joachim....@gmail.com>

The problem is that I don't know how to determine the good combination/order of servers automatically. Since I am dealing with 20+ servers, trying all possibilities is not an option. Any ideas?

Good question.

Consistent hashing is to some degree dependent on node order (you choose a node by hashing to a value
on the ring and then walk clockwise to the next node).

However, the client may be sorting nodes internally (intentionally or not). I'd suggest taking a look at SpyMemcached
source and asking on the Memcached mailing list.

Spyglass should not perform any sorting and passes server list as is to Spymemcached,
as far as I know.
--
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin
Reply all
Reply to author
Forward
0 new messages