libketama-style consistent hashing in Go

Related tags

Cryptography ketama
Overview
=====================================
ketama.go
libketama-style consistent hashing in Go

Author: Nolan Caudill ([email protected])
Date: 2011-06-04
=====================================

This is a small library to do libketama-style consistent hashing. 

A common pattern in a caching cluster (eg, memcache) is to take the hash of the key modded by
the number of cache servers to determine which node to cache to. This provides a distribution as 
even as your hashing algorithm but whenever a server is added or removed, all your keys have to rehash.

With consistent hashing, in the event of the removal of a cache node, all keys that were hashing to one 
node to (in theory) evenly distribute to the other cache nodes. The addition of a cache node works in a 
similar manner in that all nodes will evenly give up a portion of their cache keys to the new node.

This is a first pass at this and things seems to work at first glance but consider this alpha.

===========
USAGE
===========

ketama_test.go provides a working example of how to use this library.

Issues
  • public Ring type

    public Ring type

    This PR turns private hashRing type into public Ring type. That way value returned by NewRing can be passed as an argument or a property. Additionally, I made a few tiny changes to make code a little bit more idiomatic.

    opened by piotrkowalczuk 0
  • Does it support RemoveNode?

    Does it support RemoveNode?

    I just learn this algorithm and I have read this source code. I think maybe the RemoveNode(n string) function is useful to the hashRing struct.

    And other question, do you ever consider to use murmur hash to replace the sha1 hash method. I just know the performance of murmur hash is better because of it's non-cryptographic.

    opened by mnhkahn 0
Owner
Nolan Caudill
Nolan Caudill
whirlpool cryptographic hashing library

whirlpool.go A whirlpool hashing library for go Build status Setup $ go get github.com/jzelinskie/whirlpool Example package main import ( "fmt" "

Jimmy Zelinskie 21 Jan 18, 2022
Accelerate aggregated MD5 hashing performance up to 8x for AVX512 and 4x for AVX2.

Accelerate aggregated MD5 hashing performance up to 8x for AVX512 and 4x for AVX2. Useful for server applications that need to compute many MD5 sums in parallel.

High Performance, Kubernetes Native Object Storage 122 Aug 7, 2022
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

Filippo Valsorda 11k Aug 5, 2022
Consistent hashing with bounded loads in Golang

consistent This library provides a consistent hashing function which simultaneously achieves both uniformity and consistency. For detailed information

Burak Sezer 494 Jul 20, 2022
Consistent hashing with bounded loads in Golang

consistent This library provides a consistent hashing function which simultaneously achieves both uniformity and consistency. For detailed information

Burak Sezer 495 Aug 4, 2022
Consistent hashing hashring implementation.

hashring Consistent hashing hashring implementation. Overview This is an implementation of the consistent hashing hashring data structure. In general,

Sergey Kamardin 29 Apr 24, 2022
An alternative to Consistent Hashing

Weighted Rendezvous Hashing An alternative to Consistent Hashing. Evenly distributes load on node removal. ring := rendezvous.New() for _, s := range

Minoru Osuka 3 Feb 12, 2022
Consistelancer - Consistent hashing load balancer for Kubernetes

Setup minikube start kubectl apply -f k8s-env.yaml skaffold dev # test locks ku

null 1 Jan 12, 2022
A demo to show clearly how Consistent Hashing works.

Consistent Hashing Demo A simple demo of consistent hashing. Features These features have been implemented: Core consistent-hashing-algorithm Consiste

Jasonkay 11 Jul 23, 2022
LeetCode in Go with the code style strictly follows the Google Golang Style Guide

LeetCode in Go LeetCode Online Judge is a website containing many algorithm questions. Most of them are real interview questions of Google, Facebook,

null 0 Nov 13, 2021
Eventually consistent distributed in-memory cache Go library

bcache A Go Library to create distributed in-memory cache inside your app. Features LRU cache with configurable maximum keys Eventual Consistency sync

Iwan Budi Kusnanto 89 Jul 4, 2022
A revamped Google's jump consistent hash

Overview This is a revamped Google's jump consistent hash. It overcomes the shortcoming of the original implementation - not being able to remove node

Edwin 76 Aug 8, 2022
A consistent distributed data store.

Doozer What Is It? Doozer is a highly-available, completely consistent store for small amounts of extremely important data. When the data changes, it

null 3.2k Jul 31, 2022
A revamped Google's jump consistent hash

Overview This is a revamped Google's jump consistent hash. It overcomes the shortcoming of the original implementation - not being able to remove node

Edwin 76 Aug 8, 2022
hego aims to provide a consistent API for several metaheuristics

hego hego aims to provide a consistent API for several metaheuristics (black box optimization algorithms) while being performant. Even though most of

Carl 38 Jul 11, 2022
Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System".

Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System". Ships gRPC, REST APIs, newSQL, and an easy and granular permission language. Supports ACL, RBAC, and other access models.

Ory 3.5k Aug 10, 2022
The most concise and efficient algorithm of consistent hash based on golang

consistent This package of consistent is the most concise and efficient algorithm of consistent hash based on golang. Example Quick start: package mai

null 1 Dec 28, 2021
Built a causally consistent, replicated and sharded key value store with a REST API.

A causally consistent, replicated and sharded key value store built in Golang with a RESTful API. Runs through the use of a Docker container.

Dennis Pang 0 Feb 2, 2022
whirlpool cryptographic hashing library

whirlpool.go A whirlpool hashing library for go Build status Setup $ go get github.com/jzelinskie/whirlpool Example package main import ( "fmt" "

Jimmy Zelinskie 21 Jan 18, 2022
Go Perceptual image hashing package

goimagehash Inspired by imagehash A image hashing library written in Go. ImageHash supports: Average hashing Difference hashing Perception hashing Wav

Dong-hee Na 519 Aug 4, 2022
A light package for generating and comparing password hashing with argon2 in Go

argon2-hashing argon2-hashing provides a light wrapper around Go's argon2 package. Argon2 was the winner of the Password Hashing Competition that make

Andrey Skurlatov 17 Mar 29, 2022
Argon2 password hashing package for go with constant time hash comparison

argon2pw Argon2 password hashing package with constant time hash comparison Preface: Argon2 was selected as the winner of the Password Hashing Competi

Raja Bhatia 88 Jun 26, 2022
ID hashing and Obfuscation using Knuth's Algorithm

ID Obfuscation/Hashing Transformer for Go There are many times when you want to generate obfuscated ids. This package utilizes Knuth's Hashing Algorit

pj 317 Jul 2, 2022
Library for hashing any Golang interface

recursive-deep-hash Library for hashing any Golang interface Making huge struct comparison fast & easy How to use package main import ( "fmt" "git

Panos Petropoulos 6 Mar 3, 2022
Accelerate aggregated MD5 hashing performance up to 8x for AVX512 and 4x for AVX2.

Accelerate aggregated MD5 hashing performance up to 8x for AVX512 and 4x for AVX2. Useful for server applications that need to compute many MD5 sums in parallel.

High Performance, Kubernetes Native Object Storage 122 Aug 7, 2022
Hashing algorithms simplified (supports Argon2, Bcrypt, Scrypt, PBKDF2, Chacha20poly1305 and more in the future)

PHC Crypto Inspired by Upash, also implementing PHC string format Usage Currently there are two options of using this package: Import all Import speci

Reinaldy Rafli 23 Apr 23, 2022