Zig implementation of MementoHash consistent hashing algorithm.
- Add
mementohash
dependency tobuild.zig.zon
.
zig fetch --save https://github.com/tensorush/zig-mementohash/archive/<git_tag_or_commit_hash>.tar.gz
- Use
mementohash
dependency inbuild.zig
.
const mementohash_dep = b.dependency("mementohash", .{
.target = target,
.optimize = optimize,
});
const mementohash_mod = mementohash_dep.module("MementoHash");
<compile>.root_module.addImport("MementoHash", mementohash_mod);
-
Speed: the time the algorithm needs to find the node the given key belongs to.
$ zig build bench -- -s Elapsed time: 151.215ms
-
Balance: the ability of the algorithm to spread the keys evenly across the cluster nodes.
$ zig build bench -- -b Load balance: 7.84
-
Monotonicity: the ability of the algorithm to move the minimum amount of resources when the cluster scales.
$ zig build bench -- -m Number of misplaced keys after removal: 0.00% Number of misplaced keys after restoring: 0.00%