Skip to content
This repository was archived by the owner on Dec 30, 2021. It is now read-only.

Hash_ring differs slightly from libketama implementation #15

Description

We're using hash_ring + python_memcached as our memcache client. We were investigating switching to twemproxy (Twitter's memcache proxy), and were expecting that both hash_ring and twemproxy would produce identical consistent hash results since both are derived from libketama.

It turned out the results were different about 25% of the time, and on further investigation, I noticed that hash_ring has a subtle loop index issue where it uses only 12 out of the 16 bytes of the md5 digest:
https://github.com/Doist/hash_ring/blob/master/hash_ring/ring.py#L83

Libketama and twemproxy use all the 16bytes:
https://github.com/RJ/ketama/blob/master/libketama/ketama.c#L448
https://github.com/twitter/twemproxy/blob/master/src/hashkit/nc_ketama.c#L182

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions