Rust-powered key-value store ensuring strong consistency
Rust-powered key-value store ensuring strong consistency
Duva is a distributed cache server designed for high performance and scalability. It uses the Actor model to manage concurrency, clustering, and consistency, and is built in Rust.
https://github.com/user-attachments/assets/d14a85a7-5edb-4466-8bd0-f538b3d7d27d
The Actor model is well-suited for concurrent, distributed, and event-driven systems. It enables high scalability by modeling independent units of computation (actors) that communicate via message passing.
Key benefits:
The following features have been implemented so far:
Core Commands inspired by Redis
SET with optional TTLGETMGETKEYS (supports glob patterns)SAVEEXISTSDELINCRDECRCLUSTER MEETCLUSTER FORGETAdvanced Features
Protocol Support
Duva supports multiple data structures, each optimized for different use cases
> SET mykey "hello"
OK
> GET mykey
"hello"> GET missing_key
(nil)> LPUSH mylist "a" "b" "c"
(integer) 3
> LRANGE mylist 0 -1
1) "c"
2) "b"
3) "a"Our replication layer ensures strong consistency and reliability in distributed systems by managing logs across both in-memory buffers and persistent storage.
Key highlights:
Duva includes two pluggable replicated log implementations:
…There are quite a few scenarios related to this. For this, take a look at the diagram. The following is the partial sync scenario on startup:
…………This ensures that clients always see their most recent writes, even when reading from followers—providing a smooth, consistent user experience without unnecessary load on the leader.
This ensures that clients never read stale data after a successful write, improving both performance and consistency without requiring all reads to go to the leader. With this enhancement, Project X delivers stronger guarantees, lower latency, and improved scalability.
sequenceDiagram
actor C as Client
participant L as Leader
participant F as Follower
note over L,F : X:1
consensus_index:1
C->>L: write(X,5)
note over L : X:5
consensus_index:2
note over F : X:1
consensus_index:1
L->>C: consensus_index:2
C->>F: read(X,consensus_index=2)
F--)F: wait for latest consensus_index
L->>F: write(X,5,consensus_index=2)
note over F : X:5
consensus_index:2
F->>C: X:5…The system doesn't coordinate important decisions that rely on eventual consistency like gossip dissemination.
However, general information, such as node liveness can be efficiently propagated using such an algorithm.
Duva achieves failure detection using Gossip mechanism which may evolve into a hybrid gossip algorithm based on Plumtree.
Heartbeat frequency and timeout period before considering a node as failed are highly configurable:
cargo run -- --hf 100 --ttl 1500Here hf means heartbeat is sent every 100ms.
If a peer known to the given node has not sent a heartbeat within 1500ms (ttl), it is considered dead and removed from the list.
# Standalone
make leader# cluster
make leader p=6000 tp=repl0
make follower rp=6001 p=6000 tp=repl1
make follower rp=6002 p=6000 tp=repl2This server supports the RESP Protocol, enabling interaction with clients in a familiar Redis-like manner.
Future enhancements will include:
Contributions are welcome! Please fork the repository and submit a pull request for review.
Currently branch rule is enforcing that your branch matches a pattern that one of below:
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
No open issues yet, or sync has not completed.