Skip to content

quarterblue/balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

balancer GitHubPassing License

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.

Features

  • 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

Installation

Decentralized KV Storage

To use as a CLI key-value storage:

$ git clone github.com/quarterblue/balancer
$ cd balancer/
$ go mod download
$ go build -o /balancer

Load 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"
)

Usage (Chord)

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)

Commands:

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

Examples:

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-> 

References

License

Licensed under the MIT License.

Releases

No releases published

Packages

No packages published

Languages