https://github.com/keisukeyamashita/consistent
Consistent hashing with bounded loads in Golang
https://github.com/keisukeyamashita/consistent
Last synced: 7 months ago
JSON representation
Consistent hashing with bounded loads in Golang
- Host: GitHub
- URL: https://github.com/keisukeyamashita/consistent
- Owner: KeisukeYamashita
- License: apache-2.0
- Created: 2022-08-20T02:45:09.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-07T02:29:55.000Z (about 2 years ago)
- Last Synced: 2024-10-11T13:26:50.895Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# consistent
> Go written consistent hashing package inspired by Google's "Consistent Hashing with Bounded Loads"
[](https://github.com/KeisukeYamashita/consistent/actions/workflows/ci.yml)
[](https://github.com/KeisukeYamashita/consistent/actions/workflows/release.yml)[![Dependabot Badge][dependabot icon]][dependabot]
[![GoDoc Badge][godoc icon]][godoc]
[![Snyk Badge][snyk icon]][snyk]
[![FOSSA Status][fossa icon]][fossa]If you don't know the consistent hashing, please refer to [Introducing Consistent Hashing, Teiva Harsanyi](https://itnext.io/introducing-consistent-hashing-9a289769052e) to learn about it!
## References
- [Consistent Hashing with Bounded Loads on Google Research Blog](https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html)
- [Improving load balancing with a new consistent-hashing algorithm on Vimeo Engineering Blog](https://medium.com/vimeo-engineering-blog/improving-load-balancing-with-a-new-consistent-hashing-algorithm-9f1bd75709ed)
- [Consistent Hashing with Bounded Loads paper on arXiv](https://arxiv.org/abs/1608.01350)## Install
Please run to install the package:
```console
$ go get -u github.com/KeisukeYamashita/consistent
```## Configuration
```go
type Config struct {
// Hasher is responsible for generating unsigned, 64 bit hash of provided byte slice.
Hasher Hasher// Partition represents the number of partitions created on a ring.
// Partitions are used to divide the ring and assign bin and ball.
// Balls are distributed among partitions. Prime numbers are good to
// distribute keys uniformly. Select a big number if you have too many keys.
Partition int// Bins are replicated on consistent hash ring.
// It's known as virtual nodes to uniform the distribution.
ReplicationFactor int// LoadBalancingParameter is used to calculate average load.
// According to the Google paper, one or more bins will be adjusted so that they do not exceed a specific load.
// The maximum number of partitions are calculated by LoadBalancingParameter * (number of balls/number of bins).
LoadBalancingParameter float64
}
```## Usage
## Contributions
All contributions are welcome, please file a issue or a pull request 🚀
## License
[Apache License 2.0](./LICENSE).
## Acknowledgements
This package was inspired heavily by these packages:
- [buraksezer/consistent](https://github.com/buraksezer/consistent)
Thank you very much for open sourcing these hard work.
[dependabot icon]: https://img.shields.io/badge/-Dependabot-025E8C?style=flat-square&logo=dependabot&logoColor=white
[dependabot]: https://github.com/KeisukeYamashita/consistent/security/dependabot
[godoc icon]: https://img.shields.io/badge/-Go-00ADD8?style=flat-square&logo=go&logoColor=white
[godoc]: https://pkg.go.dev/github.com/KeisukeYamashita/consistent
[snyk icon]: https://img.shields.io/badge/-Snyk-4C4A73?style=flat-square&logo=snyk&logoColor=white
[snyk]: https://snyk.io/test/github/KeisukeYamashitaa/consistent/badge.svg
[fossa icon]: https://app.fossa.com/api/projects/git%2Bgithub.com%2FKeisukeYamashita%2Fconsistent.svg?type=small
[fossa]: https://app.fossa.com/projects/git%2Bgithub.com%2FKeisukeYamashita%2Fconsistent?ref=badge_small