Connect Directly with Servers from Bucket List
Hi. I'm working on a PHP application and was curious about implementing smart client-like capabilities. I was going to have it do a GET on the bucket to acquire the list of nodes, so as to get the performance gain, but was unsure of if the hashing mechanism used by the PHP client would be able to select the correct server to get/set the key, as the proxy would if performing the same request. If I set the PHP client to use consistent hashing, query for the list of nodes that a bucket uses, and then feed those into the PHP client to direct connect to (not proxy), can I be sure that it's distributed the same way as if I used the proxy connection of any single server? Thanks.
Hah, oh no, I'm not writing a full smart client. Just the portion to query for nodes and pass them into the pecl/memcache (not, memcached). Although, when I get free time I'd like to extend pecl/memcached (with the d this time!) to have full smart client capabilities after taking a complete look at spymemcached. Thanks for your quick response though, it's exactly what I was wondering. I figured they all used the same basic libketama implementation, but wanted to be sure.
Well, some years ago there was some question on the memcached mailing list wondering if spymemcached actually did the same thing as libketama. In that case, Richard Jones (from last.fm) popped up and said they were using spymemcached's implementation, so that seemed to clarify things. :)
The testing was more of a trust-but-verify situation.
If you have any other questions on how the smart client works or is intended to work, please let us know. Note that the developer kit includes a lot of documentation on the REST interface. Also, moxi now has libcurl and enough smarts to be a smart client, so there is some BSD licensed code you may be able to use for your pecl/memcached project. It's more for NorthScale Server+membase than NorthScale Server+memcached, but the REST interface is the same.
When you get this smarter pecl/memcache client going, if you're willing, it'd be great to share a blog posting or something like that with the details. Thanks!
Excellent news! It'd be awesome to have a PHP smart client.
Yes, you should see all of the items on the same nodes if both are using consistent hashing. For the most part, the clients are very consistent about consistent hashing. The proxy port does use consistent hashing.
With the Java smart client, we did a fair amount of testing to be sure it, libmemcached and the proxy implementation consistently hash the same way with consistent hashing, and they do. I'd recommend some similar testing just to be sure your PHP client is doing the same thing.
By the way, which client is it?