Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python bindings & libmemcached ketama compatibility #3

Merged

Conversation

mikeyk
Copy link
Contributor

@mikeyk mikeyk commented Dec 26, 2011

The Python bindings are written with ctypes and support adding, removing, printing, and finding nodes.

For libmemcached compatibility, their implementation of ketama only uses the lower 32 bits, and for the node name appends the position in the ring as "-index" instead of just "index". I made this a compile-time option.

Mike Krieger added 3 commits December 23, 2011 01:14
If compiling with LIBMEMCACHED_COMPAT, only
the low 32 bits of the md5 hash will be used,
and a "-" will be appended between the node
name and the node index
@chrismoos
Copy link
Owner

This is great, thanks! I'll merge this and maybe add using libmemcached compatibility as a runtime option. What do you think?

chrismoos added a commit that referenced this pull request Dec 26, 2011
…541f9

Add Python bindings & libmemcached ketama compatibility
@chrismoos chrismoos merged commit e4face9 into chrismoos:master Dec 26, 2011
@mikeyk
Copy link
Contributor Author

mikeyk commented Dec 26, 2011

Runtime would be great—wasn't sure if it would be useful beyond our use-case (we have an existing pool that's libmemcached-hashed) so made it compile time but I think run-time would be cleaner than #ifdefs :)

@chrismoos
Copy link
Owner

Okay I'll update that, maybe throw in a test too to ensure the compatibility. Is there a reason you chose to use hash-ring over ketama or libmemcached?

@mikeyk
Copy link
Contributor Author

mikeyk commented Dec 26, 2011

Our app servers run Python, and pylibmc + libmemcached uses non-Python sockets and plays not-very-nicely with gevent's cooperative multithreading, so we're moving to ultramemcached, which is very fast but has no hash ring support.

First i dropped in the python hash_ring module, but found that we were spending way too much time in Python doing the hashing / ring calculations, so moving that into C was the next step. I didn't like libketama's approach of reading its input from a file (the Python bindings for example create a temp file and .write() into it), and hash-ring was nicely self-contained, so went with that.

Mike Krieger

On Monday, December 26, 2011 at 5:03 PM, Chris Moos wrote:

Okay I'll update that, maybe throw in a test too to ensure the compatibility. Is there a reason you chose to use hash-ring over ketama or libmemcached?


Reply to this email directly or view it on GitHub:
#3 (comment)

@chrismoos
Copy link
Owner

Cool, thanks for the info and the contribution. I'm going to push the change for the option at runtime with hash_ring_set_mode() in a bit. Just need to update some bindings.

@LittlePeng LittlePeng mentioned this pull request Oct 30, 2014
nerandell pushed a commit to nerandell/hash-ring that referenced this pull request Feb 17, 2017
nerandell pushed a commit to nerandell/hash-ring that referenced this pull request Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants