Balancer is a fault-tolerant implementation of a modified Chord distributed hash tables. It can be used as a standalone load balancer for distributed systems or a fully functional kv storage (with interactive cli). As a load balancer library, the keys are distributed using consistent hashing with bounded loads (w/ free random jumps) to avoid cascading failure. As a kv storage, an interactive cli provides easy access. It can be used as a library to build decentralized peer-to-peer application on top of the chord ring. It exposes customizable replication factor and implements multiple chords rings to provide fault-tolerance.
- Easy to use
- Fault-tolerent with customizable replication factor
- Flexible (use as library or cli)
- Standalone load balancer
- Fully functional kv storage
- Performant gRPC networking
To use as a CLI key-value storage
:
$ git clone github.com/quarterblue/balancer
$ cd balancer/
$ go mod download
$ go build -o /balancer
To use as a load balancer library
:
$ cd projectdir/
$ go get github.com/quarterblue/balancer
Import into your Go project:
import (
"github.com/quarterblue/balancer"
)
You can use it has an interactive decentralized Key-Value storage:
$ go run main.go -port 9001 -ring -cli
Flags:
-address string
This machines IP address. (default localhost)
-join string
IP Address to join initially. (default "")
-port string
Port that this node should listen on. (default "9001")
-ring
Boolean to start a ring. (default false)
-cli
Boolean to start CLI mode. (default false)
Input the CLI command for the chord ring CMD:
$ [balancer] CMD->
Command | Description | Usage |
---|---|---|
get |
Retrieve a value | get key |
put |
Store a key value pair | put key value |
delete |
Delete a key value pair | delete key |
dump |
Displays all key value pair stored on the local node | dump all |
leave |
Leaves the chord ring by notifying | leave |
To retrieve a kv pair:
$ [balancer] CMD-> get whatkey
$ [balancer] OUT-> value: merkletree
$ [balancer] CMD->
To store or delete a kv pair:
$ [balancer] CMD-> put anotherkey somevalue
$ [balancer] OUT-> stored: somevalue
$ [balancer] CMD->
$ [balancer] CMD-> delete anotherkey
$ [balancer] OUT-> deleted: anotherkey
$ [balancer] CMD->
- Chord: A Scalable Peer-to-peer Lookup Protocol for Internet Applications
- Consistent Hashing with Bounded Loads
- Revisiting Consistent Hashing With Bounded Loads
- Rollerchain: a DHT for Efficient Replication
Licensed under the MIT License.