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 hashing client #59
Conversation
With babb8c0 I added support for failover. This doesn't recover dead servers yet but it will remove misbehaving servers from the pool. |
8879147 brings dead servers back into rotation after the |
With 2470508 this is fairly feature complete. There is a lot of polish I need to throw in like better logging / error checking and plenty more unit tests but its definitely working. |
I did a quick first pass on the code, and it looks good! I'll take a closer look this week, probably on Wednesday (that's the first day I don't have wall-to-wall meetings). We use a memcache proxy internally, so we haven't needed this, but it's been high on my list of things to add for people that aren't using a proxy. |
@cgordon Sounds good, what proxy do you guys use? We currently use |
@cgordon One thing I thought about with this is making |
@@ -684,7 +650,7 @@ def _fetch_cmd(self, name, keys, expect_cas): | |||
result[key] = value | |||
else: | |||
raise MemcacheUnknownError(line[:32]) | |||
except Exception: | |||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the "as e" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, added that during a debugging session, wasn't supposed to be included in the commit
@sontek The code looks great, I just have a few cosmetic comments and one comment about the overall contract of the methods. Let's talk about that a little bit when you have time. Also, we're currently using mcrouter, and previously used twemproxy. I haven't been very involved in those decisions, but my understanding is that mcrouter is the better of the two. |
@cgordon Addressed all of your concerns in a935261, what do you think about the overall contract? I initially was trying to clean the contract up with this but I think we can do that slower with I'm not completely against having the hashing client raise an exception but it would mean you would have to opt-in to graceful failover (unless we made it not raise exceptions by default) |
@cgordon The big question I have about this is if the murmur3/clandestined hash client should be the default. clandestined uses What I think might be better is provide a less efficient/less consistent default using CRC32 which is pure python and provide an extras (client.ext.murmur3) that can be used like:
|
@sontek I agree with your last comment, that we should make the C dependency possible but optional. I took a look at the branch and it looks great to me. |
Remove dependency on clandestined and use pure python murmur3
@sontek Sorry for the long pause, was out of town for the 4th. Would you mind re-basing this change to pick up the documentation and test changes that we've already merged? The rest of the code looks great, but I just want to do one more pass through it before merging. |
@sontek I'm ready to merge this change, but it needs to be merged with the documentation and testing changes from the last week. Can you take care of that? |
@cgordon Yeah, sorry I was busy last week but I'll clean it up in the next few days! :) |
@sontek Awesome! Just double checking that I wasn't dropping the ball. Very excited about this change :) |
Make ignoring exceptions optional
…hing_client Conflicts: docs/apidoc/pymemcache.test.rst
@cgordon I think its ready for review! Want to take it for a spin on pinterest codebase to make sure I didn't break any backwards compatibility? |
clandestined already doesn't compile murmur if on PyPy/PyPy3 and uses a pure python implementation of murmur instead following ewdurbin/clandestined-python#8 so that's a non-issue. |
@thedrow Yeah, I think the important part is that |
can we please add a build job that tests this both with clandestined and without? |
1 similar comment
can we please add a build job that tests this both with clandestined and without? |
@thedrow I'll document how to use it instead of just recommending it in the docs |
LGTM. Thanks @sontek! |
@sontek, separately, can you switch the readthedocs page to use the master repository so the docs are up to date? It looks like they point at your personal branch right now. |
@cgordon Done! Do you have a readthedocs user? I can add you on there as well |
@sontek I just created a user on readthedocs.org, I'm "charles.gordon". |
This is the beginning of how I would expect the hashing client to work. It is built off of #51 so that would need to be merged first.
It is an alternative to #44 and a fix for #52
Things left to do:
For failover support
HashClient
will support the following settings:retry_attempts
- After retry_attempts has been hit it will mark the server as dead and remove it from the rotation.retry_timeout
- It will wait this long in between retriesdead_timeout
- Afterretry_attempts
have been reached it will wait this long before attempting to add the server back into the pool.Once a server is marked dead the keys that were allocated to it will be rebalanced across the nodes that are still up.
You can use this like this: