Skip to main content

Module ketama

Module ketama 

Source
Expand description

Ketama consistent-hashing continuum.

For every live server we generate KETAMA_POINTS_PER_SERVER (160) continuum points proportional to the server’s weight. Each set of 4 points is computed from a single MD5 digest of "<name>-<idx>", pulling 32-bit slices out of the digest at offsets 0, 4, 8, and 12. Lookups walk the sorted continuum and pick the first point with a token strictly greater than the requested hash, wrapping back to the beginning when the lookup falls past the end.

Structs§

Continuum
Sorted continuum, ready for dispatch.
ContinuumPoint
One entry on the continuum: a token and the index of the server that owns it.
ServerSpec
Specification for one server in the continuum.

Constants§

MAX_HOSTLEN
Maximum length of "<name>-<idx>" used to seed each digest.
POINTS_PER_HASH
Each MD5 digest yields 4 continuum points.
POINTS_PER_SERVER
160 points per server.