https://github.com/authzed/consistent
gRPC Balancer that routes requests using a consistent hashring
https://github.com/authzed/consistent
consistent-hash-ring grpc grpc-client grpc-go load-balancer
Last synced: 6 months ago
JSON representation
gRPC Balancer that routes requests using a consistent hashring
- Host: GitHub
- URL: https://github.com/authzed/consistent
- Owner: authzed
- License: apache-2.0
- Created: 2023-07-31T06:44:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-27T18:47:41.000Z (7 months ago)
- Last Synced: 2025-09-29T12:52:51.018Z (6 months ago)
- Topics: consistent-hash-ring, grpc, grpc-client, grpc-go, load-balancer
- Language: Go
- Homepage:
- Size: 139 KB
- Stars: 45
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE-OF-CONDUCT.md
Awesome Lists containing this project
README
# consistent
[](https://godoc.org/github.com/authzed/consistent)
[](https://authzed.com/discord)
[](https://twitter.com/authzed)
This package implements a gRPC Balancer that routes requests based upon a consistent hashring.
The hashing algorithm is customizable, but xxhash is recommended.
It was originally built to serve [SpiceDB](https://github.com/authzed/spicedb), but has been extracted from that repository to be made available for other projects.
In order to use this balancer, you must:
1. Register the balancer (typically in `main`):
```go
balancer.Register(consistent.NewBuilder(xxhash.Sum64))
```
2. Configure the connections:
```go
// This is using the defaults, but you can create your own config.
grpc.Dial(addr, grpc.WithDefaultServiceConfig(consistent.DefaultServiceConfigJSON))
```
## Acknowledgements
This project is a community effort fueled by contributions from both organizations and individuals.
We appreciate all contributions, large and small, and would like to thank all those involved.
A large portion of the structure of this library is based off of the example implementation in [grpc-go](https://github.com/grpc/grpc-go).
That original work is copyrighted by the gRPC authors and licensed under the Apache License, Version 2.0.