A distributed hash table using the Chord lookup protocol, implemented in Go.
A demo can be found here
- Implement a functioning DHT
- Implement the Chord protocol for efficient node lookup
- Extend Chord with data replication to provide increased availability
- Learn gRPC and protocol buffers
Must have go version 1.12 or greater installed on the host in order to build.
To build the chord server and client, simply run:
make server
make client
The executable named chord will be created in both the server and client folders.
Below are instructions for configuring your chord servers and clients.
In ./server/config.yaml specify information about your server, like its ip and port. Here is an example:
addr: 172.0.0.1
port: 8001
logging: false
In ./client/config.yaml specify the address of the chord server to send client requests to. Here is an example:
addr: 172.0.0.1:8001
Below are instructions for running a chord server or client.
To create a new chord ring:
./server/chord create
To join an existing chord ring:
./server/chord join <ip> <port>
To put a new key-value pair into the DHT:
./client/chord put <key> <val>
To get the value for a key in the DHT:
./client/chord get <key>
To locate the node responsible for a key in the DHT (for debugging purposes):
./client/chord locate <key>
To run multiple chord servers locally, run the test files in ./test.
To start node1 listening on 0.0.0.0:8001, run
go run test/node1.go
To start node2 listening on 0.0.0.0:8002, run
go run test/node2.go
There are 5 test files, so this allows you to run 5 separate servers locally.