The goal of the project is a high-performance distributed key-value store with consistent hashing, sharding, and fault tolerance. We implement the KVS in Rust. For consensus between nodes, we use an out of the box implementation of Raft in Rust and adapt it to use RPCs as the communication mechanism. We build our own implementation of consistent hashing using Cache Array Routing Protocol (CARP) and demonstrate (with benchmarks) that our system efficiently and evenly partitions the data across all nodes.
We use CARP to create a consistent hash ring for data sharding. Each node on the ring is a Raft cluster, which provides data replication. Routing to the correct cluster is done client-side. The client needs to request the CARP config before using it to send requests to the right place.
To see the a single Raft cluster at work, run the following:
sh scripts/test-single-cluster.shTo see multiple Raft clusters at work, run the following:
sh scripts/test-multiple-clusters.shYou can also run cargo test to make sure everything works properly. This will test the CARP implementation and the Raft implementation.
Run cargo bench (after running cargo run --bin admin --release in a separate terminal to launch the clusters) to run several benchmarks.
bin/main.rscan be used to start a Raft node. This is used bytest-single-cluster.shfor testing purposes.bin/admin.rsis a sample admin to launch clusters of Raft nodes based on the configuration inConfig.toml.bin/client.rsis a sample client application that uses the client inkvclient.rsto read/write.lib.rscontains the starting point and core implementation of creating a Raft node.networkcontains all the files needed for a client to interact with the system and for the Raft nodes to talk to each other.api.rscontains the applications API that can be called by a client node (seeraft_node.rsfor more info.)management.rscontains the API used to set up the Raft network. This API is exposed via an Axum HTTP server.error.rscontains a custom error type used to make Axum handlers easier to work with.raft.rsandraft_network_impl.rsimplement the communication of Raft nodes. This is done via RPCs.raft.rsimplements the gRPC server.raft_network_impl.rsimplements the actual communication between nodes.
raft_node.rsimplements a raft node that can be used externally. This implementation is used bytests/test_raft_cluster.rsto test whether the implementation works as expected.store.rsimplements the Log Store and State Machine used by Raft.carp.rsimplements the Cache Array Routing Protocol.kvclient.rsimplements a client that can be used to interact with the distributed key-value store.cluster_manager.rsimplements a cluster manager that starts and shuts down a local cluster (this could be modified to launch across servers on the cloud).
- Openraft as the underlying Raft consensus protocol.
- Custom CARP implementation. See
carp.rsfor more info. - Toy-RPC, an RPC implementation that mimics golang's
net/rpc. - Rocksdb, a library that provides an embeddable, persistent key-value store for fast storage.
- Axum as the web framework.
- Tracing for asynchronous logging.