Very simple implementation of a distributed key-value store leveraging consistent hashing for mapping a key to a peer.
Every key has a preference list of [hash(key) % num_peers, hash(key) + N % num_peers]
.
The hash function used is MD5.
- If a peer is not the last in this range, it will attempt to replicate the data to the next peer.
- If a client's request to a peer fails, it will attempt the next peer in the preference list either until success or until there are no peers left.
- Fire up two peers
Peer_0
andPeer_1
- Client makes a
Put()
call for a blob of data with a key that maps toPeer_0
. This request is only made toPeer_0
Peer_0
replicates the data via. put request toPeer_1
(if the preference list were longer,Peet_1
would do the same)Peer_0
is shut down- Client makes a
Get()
call for the same key. Its request forPeer_0
fails, so it makes a successful call toPeer_1
which is the next in the preference list for that key - The resulting data is written to a new file
All communication happens over http
Expects a GET
http-request to /api/<key>
and returns binary data in the
form of an http response with Content-Type: application/octet-stream
in the
header.
Expects a PUT
http-request to /api/<key>
with binary data in the form of
an http request containing Content-Type: application/octet-stream
in the
header.
Check the /client_protocol
and /server_protocol
readme files for
information on configuration.