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

Distribution is not uniform #10

Open
paulmach opened this issue Aug 18, 2015 · 12 comments
Open

Distribution is not uniform #10

paulmach opened this issue Aug 18, 2015 · 12 comments

Comments

@paulmach
Copy link

Please see strava/go.serversets#7 for more details. That library uses a vendored version of this consistent hash library. What I'm seeing is a distribution like:

  58856 - 10.0.16.69:11211
  18389 - 10.0.22.188:11211
  22755 - 10.0.26.214:11211

(count - server for 10k random strings)

This uneven distribution is what we're seeing in production so I don't think it's an issue with the random key generation. Have you guys encountered this before? Am I using the code wrong?

@andyxning
Copy link

I run into this situation also, i think the crc32 hash algorithm is not suitable to be used to distribute keys.

@Ewan-GrandSlam
Copy link

I see something similar, two of 3 instances appear to be relatively even and as soon as you add a third it gets very uneven

@jian-en
Copy link

jian-en commented Mar 1, 2018

I come with the same problem. maybe the hash returns a uint32 key. the space is not big enough? I am not sure.

@saswatp
Copy link

saswatp commented Mar 9, 2018

+1 Same issue.

@dawei101
Copy link

+1

@mikegleasonjr
Copy link

Increase the replicas (ie.: 100)

@andyxning
Copy link

Increase the replicas (ie.: 100)

This can just decrease the in-balance but can not resolve it completely.

@mikegleasonjr
Copy link

Increase the replicas (ie.: 100)

This can just decrease the in-balance but can not resolve it completely.

I don't think we can achieve perfect balance..

I am using another library, but using a replicas of 100 coupled with the fnv32a hash gives me pretty uniform results...

@andyxning
Copy link

andyxning commented Sep 20, 2019

@mikegleasonjr

I don't think we can achieve perfect balance..
I am using another library, but using a replicas of 100 coupled with the fnv32a hash gives me pretty uniform results...

I agree. fnv32a is a pretty good hash function for use in consistent hash for its uniform distribution.

@patrickxb
Copy link
Collaborator

I added an option to use fnv32a: UseFnv.

    x := New()
    x.UseFnv = true
    x.Add("abcdefg")
    x.Add("hijklmn")
    x.Add("opqrstu")

There are some tests that show it has a more uniform distribution.

@chasememeda
Copy link

still not uniformly distributed.... and it differs A LOT when different elements are added, which is very confusing...... // why the name of elements will influence the result so much???

I finally solved the problem with the solution from this: strava/go.serversets@cb6a0bf

@jiangz222
Copy link

jiangz222 commented May 22, 2021

Since this repo is not maintained?
Make a progress in my repo
Support custom hash function, and use Murmur3 to make distribution more uniform.

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

No branches or pull requests

10 participants