Skip to content

codejitsu/KavaDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

KavaDB

Simple distributed KV store with consistent hashing and gossip protocol written in Rust for maximum efficiency.

Supported operations

Consistent Hashing

The system uses consistent hashing to distribute keys across multiple nodes in the cluster. Each node is assigned a position on the hash ring, and keys are mapped to nodes based on their hash values. This allows for efficient key distribution and minimizes data movement when nodes are added or removed.

  • PUT key value
  • READ key
  • DELETE key
  • BATCHPUT key1 value1 key2 value2 ...

No consistent hashing (TODO)

This command does not use consistent hashing and queries all keys in the local node only.

  • RANGE start_key end_key

Features

  • In-memory storage with optional persistence (TODO)
  • Pluggable storage backends (in-memory, file-based, etc.)
  • Gossip protocol for node discovery and cluster membership
  • Simple command-line interface for interacting with the KV store
  • Basic error handling and logging
  • Unit tests for core functionality
  • Basic consistent hashing for key distribution
  • Virtual nodes for better distribution

Prerequisites

  • Rust 1.70+
  • Cargo
  • Git

Getting Started

  1. Clone the repository:

    git clone https://github.com/codejitsu/KavaDB.git
  2. Install Rust and Cargo if you haven't already. You can follow the instructions at rustup.rs.

  3. Change into the project directory:

    cd KavaDB/node
  4. Build the project:

    cargo build
  5. Run the project:

    cargo run

The node will peak the the kava.conf file in the current directory for configuration by default.

Example Usage with Multiple Nodes

To simulate a distributed environment, you can run multiple instances of the application with different configuration files.

Open multiple terminal windows and run the following commands:

# Terminal 1
cargo run -- kava.conf

# Terminal 2
cargo run -- kava2.conf

# Terminal 3
cargo run -- kava3.conf

Now you can interact with any of the nodes using the command-line interface. For example, in Terminal 1, you can run:

echo "PUT nickname codejitsu" | nc localhost 3001

Now you can read the value from any node:

echo "READ nickname" | nc localhost 3002

Configuration

The application can be configured using the kava.conf file located in the project directory.

There are three config files provided for testing:

  • kava1.conf
  • kava2.conf
  • kava3.conf

Each config file represents a different node in the cluster. You can run multiple instances of the application with different config files to simulate a distributed environment.

Running Tests

To run the tests, use the following command:

cargo test

About

Simple distributed KV store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages