Coursework: Distributed systems
Distributed key-value naming service
A Java hash-ring naming service: a bootstrap server and name servers that look up, insert and delete keys, and rebalance key ranges as servers join and leave.
What it is
A naming service stores key and value pairs across several machines and has to answer "which machine holds this key?" quickly, even while machines come and go.
I implemented a small version in Java. Keys live on a ring of 1024 positions, each name server owns a range of that ring, and when a server joins or leaves, only the affected range moves.
My part
I wrote the bootstrap server and the name server for the course, individually.
Course project for Distributed Computing Systems. It demonstrates the mechanics of consistent hashing, not a production system.
Stack
- Java
- TCP sockets
- Consistent hashing
- Command-line client
What is inside
Three roles communicate over sockets: a bootstrap server, name servers and a user command interface.
01
Bootstrap server
Acts as the node with id 0, loads the initial key-value pairs from a config file, keeps the map of ring members, and receives lookup, insert and delete commands, forwarding each to the owner.
02
Name servers
Each name server owns a range of the key space 0 to 1023, joins and leaves dynamically, and tracks its predecessor and successor on the ring.
03
Join and leave
When membership changes, the affected key range is reassigned and the keys in it are transferred to the new owner, so the rest of the ring is untouched.
04
Storage
Pairs live in memory and are seeded from the config file. Nothing is persisted, and this page does not claim recovery after a crash.