Allows specification of weight by range#2
Open
israelshirk wants to merge 2 commits intomasterfrom
unknown repository
Open
Allows specification of weight by range#2israelshirk wants to merge 2 commits intomasterfrom unknown repository
israelshirk wants to merge 2 commits intomasterfrom
unknown repository
Conversation
added 2 commits
February 2, 2014 17:46
Collaborator
|
I think this feature is not necessary.As both of the range [0,50] and the integer 50 equivalent to xrange(0,50). |
Author
|
I'm not sure what you mean - could you give an example? |
Collaborator
|
I mean that the RangeHash({'redis://1.1.1.1:6379': [0, 100]}) could be instead with the ConsistentHash('redis://1.1.1.1:6379': 100}.Refer to the ‘def _node_keys(self, node)’ routine, they are same. |
Collaborator
|
Because the hashing is independent of hostname, so after connection_hasher.add_nodes({'redis://2.2.2.2:6379': [0, 50]}), the range [0, 50] will hit 2.2.2.2, it will cause mishit the range [0, 50] of the original mapping. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows specification of weight by range rather than by integer value.
Useful when you need to scale up on a production server without interruption/cache busting. Example:
Scaling
connection_hasher = RangeHash({'redis://1.1.1.1:6379': [0, 100]})connection_hasher.add_nodes({'redis://2.2.2.2:6379': [0, 50]})Over time, you can scale up more or less indefinitely without any downtime.
Failover
You can also handle failover gracefully since hashing is independent of hostname - starting the example above, you'd run
connection_hasher.remove_nodes(['redis://2.2.2.2:6379])thenconnection_hasher.add_nodes({'redis://3.3.3.3:6379': [0, 50]})to handle failing over from 2.2.2.2 to 3.3.3.3 with no service interruptions, cache stampede, and only minor loss of consistency.Includes the other commit, but you might want this addition structured differently, or have it in a separate distribution - LMK if that's the case. Thanks!