Skip to content

About

A high-availability distributed key-value store built in Go. Implements Consistent Hashing for sharding, Tunable Consistency (Quorums), and Gossip Protocol for failure detection. Features a custom Bitcask-style storage engine with Write-Ahead Logging (WAL) for data durability. Modeled after Amazon Dynamo.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Distributed Key-Value Store with Tunable Consistency

A Production-Grade Dynamo-Style Storage System

Go Version License Architecture CAP Author

A high-performance, fault-tolerant distributed key-value storage system inspired by Amazon's Dynamo whitepaper

Features β€’ Quick Start β€’ Architecture β€’ API β€’ Configuration β€’ Testing


πŸ“‹ Table of Contents


🎯 Overview

Distributed Key-Value Store with Tunable Consistency is a distributed key-value store that implements the core principles from Amazon's groundbreaking Dynamo paper. It's designed for scenarios requiring:

  • High Availability - The system remains operational even when nodes fail
  • Horizontal Scalability - Add more nodes to handle increased load
  • Low Latency - Optimized for fast reads and writes
  • Eventual Consistency - With tunable consistency levels for flexibility

πŸŽ“ Educational Value

This project serves as an excellent learning resource for understanding:

  • Distributed systems concepts
  • Consensus and replication strategies
  • Failure detection mechanisms
  • Storage engine design

✨ Features

Core Distributed Systems Features

Feature Description
Consistent Hashing Data partitioning using a 64-bit hash ring with virtual nodes
Replication Configurable N-way replication across preference list nodes
Tunable Consistency Quorum-based operations (W + R > N guarantees)
Gossip Protocol Peer-to-peer failure detection and membership dissemination
Hinted Handoff Temporary storage for unavailable nodes
Read Repair Automatic consistency healing during read operations
Vector Clocks Causality tracking for conflict detection
Last-Write-Wins Timestamp-based conflict resolution

Storage Engine (Bitcask Model)

Feature Description
Append-Only Writes All writes are sequential appends for durability
In-Memory Index O(1) key lookups with single disk seek
CRC Checksums Data integrity verification
Compaction Space reclamation from deleted/overwritten keys
Crash Recovery Automatic index rebuild from log on restart

Operations & Management

Feature Description
RESTful API Simple HTTP/JSON interface
Admin Endpoints Cluster status, statistics, ring visualization
Graceful Shutdown Clean shutdown with data persistence
Configurable CLI flags, config files, or environment variables

πŸ’» System Requirements

Requirement Minimum Recommended
Go Version 1.21+ 1.22+
RAM 512MB per node 2GB per node
Disk SSD recommended NVMe for best performance
OS Linux, macOS, Windows Linux (production)
Network 1Gbps 10Gbps for high throughput

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/bhushanasati25/Distributed-Key-Value-Store-with-Tunable-Consistency.git
cd Distributed-Key-Value-Store-with-Tunable-Consistency

# Install dependencies
go mod download

# Build the binary
make build

# Verify installation
./bin/dynamo --version

Run Single Node (Development)

./bin/dynamo \
  --node-id=node1 \
  --port=8001 \
  --data-dir=./data/node1

Run 3-Node Cluster (Production-like)

Terminal 1:

./bin/dynamo --node-id=node1 --port=8001 --gossip-port=7001 --data-dir=./data/node1

Terminal 2:

./bin/dynamo --node-id=node2 --port=8002 --gossip-port=7002 --data-dir=./data/node2 \
  --seeds=127.0.0.1:7001

Terminal 3:

./bin/dynamo --node-id=node3 --port=8003 --gossip-port=7003 --data-dir=./data/node3 \
  --seeds=127.0.0.1:7001,127.0.0.1:7002

Or use the convenience script:

make cluster      # Starts 3 nodes
make stop-cluster # Stops all nodes

Basic Operations

# Store a value
curl -X PUT http://localhost:8001/kv/user:1001 \
  -H "Content-Type: application/json" \
  -d '{"value": "{\"name\": \"John\", \"email\": \"john@example.com\"}"}'

# Retrieve a value
curl http://localhost:8001/kv/user:1001

# Delete a value
curl -X DELETE http://localhost:8001/kv/user:1001

# Check cluster status
curl http://localhost:8001/admin/status | jq

πŸ— Architecture

High-Level System Design

                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚    Client App   β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                             β”‚
                                             β”‚ HTTP/REST
                                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚              Load Balancer                  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                             β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                              β”‚                              β”‚
              β–Ό                              β–Ό                              β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚     Node 1      │◄──────────►│     Node 2      │◄──────────►│     Node 3      β”‚
    β”‚   (Coordinator) β”‚   Gossip   β”‚   (Replica)     β”‚   Gossip   β”‚   (Replica)     β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€            β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€            β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚            β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚            β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
    β”‚ β”‚  Hash Ring  β”‚ β”‚            β”‚ β”‚  Hash Ring  β”‚ β”‚            β”‚ β”‚  Hash Ring  β”‚ β”‚
    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚            β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚            β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚            β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚            β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
    β”‚ β”‚  Bitcask    β”‚ β”‚            β”‚ β”‚  Bitcask    β”‚ β”‚            β”‚ β”‚  Bitcask    β”‚ β”‚
    β”‚ β”‚  Storage    β”‚ β”‚            β”‚ β”‚  Storage    β”‚ β”‚            β”‚ β”‚  Storage    β”‚ β”‚
    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚            β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚            β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Request Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Client  │────►│ Coordinator │────►│  Hash Ring   │────►│ Preference  β”‚
β”‚          β”‚     β”‚    Node     β”‚     β”‚   Lookup     β”‚     β”‚    List     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                  β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                        β”‚                                         β”‚
                        β–Ό                                         β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Replicate   β”‚                        β”‚   Replicate   β”‚
                β”‚   to Node A   β”‚                        β”‚   to Node B   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚                                         β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚ Quorum Check  β”‚
                              β”‚  (W acks)     β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚    Response   β”‚
                              β”‚   to Client   β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Consistent Hashing Ring

                           0
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                   /               \
                  /                 \
           N3-v2 ●                   ● N1-v1
                /                     \
               /                       \
        N2-v1 ●                         ● N2-v2
             β”‚                           β”‚
             β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
             β”‚      β”‚   Ring    β”‚        β”‚
             β”‚      β”‚  64-bit   β”‚        β”‚
             β”‚      β”‚   Hash    β”‚        β”‚
             β”‚      β”‚   Space   β”‚        β”‚
             β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
             β”‚                           β”‚
        N1-v2 ●                         ● N3-v1
              \                         /
               \                       /
                \                     /
                 ● N1-v3       N2-v3 ●
                  \                 /
                   \               /
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                          2⁢⁴

πŸ“‘ API Reference

Key-Value Operations

Store a Value

PUT /kv/{key}
Content-Type: application/json

{
  "value": "your data here",
  "consistency": "quorum"  // optional: "one", "quorum", "all"
}

Response (200 OK):

{
  "status": "ok",
  "key": "mykey",
  "version": 1702934567890123456
}

Retrieve a Value

GET /kv/{key}?consistency=quorum

Response (200 OK):

{
  "key": "mykey",
  "value": "your data here",
  "version": 1702934567890123456
}

Response (404 Not Found):

{
  "error": "Not Found",
  "code": 404,
  "message": "key not found"
}

Delete a Value

DELETE /kv/{key}

Response (200 OK):

{
  "status": "ok",
  "key": "mykey"
}

Admin Operations

Cluster Status

GET /admin/status

Response:

{
  "node_id": "node1",
  "address": "127.0.0.1:8001",
  "uptime": "2h 15m 30s",
  "keys": 15420,
  "storage": {
    "active_keys": 15420,
    "deleted_keys": 123,
    "data_file_size_bytes": 52428800,
    "total_reads": 1250000,
    "total_writes": 450000
  },
  "cluster": {
    "size": 3,
    "nodes": [
      {"id": "node1", "address": "127.0.0.1:8001", "state": "alive"},
      {"id": "node2", "address": "127.0.0.1:8002", "state": "alive"},
      {"id": "node3", "address": "127.0.0.1:8003", "state": "alive"}
    ]
  }
}

Ring Information

GET /admin/ring

Storage Statistics

GET /admin/stats

List All Keys

GET /admin/keys

Health Check

GET /health

Consistency Levels

Level Replicas Required Use Case
one 1 Maximum availability, single-node testing
quorum ⌈(N+1)/2βŒ‰ Balanced consistency/availability (default)
all N Maximum consistency, lowest availability

βš™οΈ Configuration

Command Line Flags

Flag Type Default Description
--node-id string hostname Unique identifier for this node
--address string 127.0.0.1 IP address to bind to
--port int 8080 HTTP API port
--gossip-port int 7946 UDP port for gossip protocol
--data-dir string ./data Directory for persistent storage
--seeds string "" Comma-separated seed node addresses
--replication int 3 Replication factor (N)
--read-quorum int 2 Read quorum (R)
--write-quorum int 2 Write quorum (W)
--vnodes int 150 Virtual nodes per physical node
--config string "" Path to JSON config file
--version bool false Show version and exit

Configuration File (JSON)

{
  "node_id": "production-node-1",
  "address": "10.0.1.10",
  "port": 8080,
  "gossip_port": 7946,
  "data_dir": "/var/lib/distributed-kvstore",
  "seed_nodes": [
    "10.0.1.11:7946",
    "10.0.1.12:7946"
  ],
  "max_file_size": 104857600,
  "sync_writes": false,
  "compact_interval": 300,
  "replication_factor": 3,
  "read_quorum": 2,
  "write_quorum": 2,
  "virtual_nodes": 150
}

Environment Variables

All config options can also be set via environment variables with the DYNAMO_ prefix:

export DYNAMO_NODE_ID=node1
export DYNAMO_PORT=8001
export DYNAMO_REPLICATION_FACTOR=3

πŸ§ͺ Testing

Unit Tests

# Run all unit tests
make test

# Run with verbose output
go test -v ./internal/...

# Run specific package tests
go test -v ./internal/storage/...
go test -v ./internal/ring/...

Integration Tests

# Requires building first
make build

# Run integration tests
make test-integration

# Or manually
go test -v -tags=integration ./test/integration/...

Test Coverage

make coverage

# View coverage report in browser
open coverage.html

Load Testing

# Built-in load tester
make load-test

# Custom parameters
go run test/load/benchmark.go \
  -target=http://localhost:8001 \
  -requests=10000 \
  -concurrency=50 \
  -write-ratio=0.3

Chaos Testing

# Start cluster
make cluster

# Write some data
for i in {1..100}; do
  curl -X PUT "http://localhost:8001/kv/key$i" -d "{\"value\":\"value$i\"}"
done

# Kill a node (simulates failure)
kill $(lsof -t -i:8002)

# Verify reads still work (quorum of 2 from remaining nodes)
curl http://localhost:8001/kv/key50

# Restart killed node
./bin/dynamo --node-id=node2 --port=8002 --gossip-port=7002 \
  --data-dir=./data/node2 --seeds=127.0.0.1:7001

πŸ“Š Benchmarks

Test Environment

  • Hardware: MacBook Pro M1, 16GB RAM
  • Cluster: 3 local nodes
  • Data: Random 1KB values

Results

Metric Single Node 3-Node Cluster
Write Throughput 15,000 ops/sec 5,000 ops/sec
Read Throughput 45,000 ops/sec 12,000 ops/sec
P50 Latency 0.5ms 2ms
P99 Latency 3ms 15ms
P99.9 Latency 8ms 35ms

Note: Cluster throughput is lower due to quorum requirements and network round-trips.


πŸ“ Project Structure

Distributed-Key-Value-Store-with-Tunable-Consistency/
β”œβ”€β”€ cmd/
β”‚   └── dynamo/
β”‚       └── main.go                 # Application entry point
β”‚
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ server.go               # HTTP server setup
β”‚   β”‚   β”œβ”€β”€ handlers.go             # Request handlers
β”‚   β”‚   └── middleware.go           # Logging, CORS, recovery
β”‚   β”‚
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── config.go               # Configuration management
β”‚   β”‚
β”‚   β”œβ”€β”€ gossip/
β”‚   β”‚   β”œβ”€β”€ membership.go           # Cluster membership list
β”‚   β”‚   β”œβ”€β”€ detector.go             # Failure detection
β”‚   β”‚   └── protocol.go             # UDP gossip protocol
β”‚   β”‚
β”‚   β”œβ”€β”€ replication/
β”‚   β”‚   β”œβ”€β”€ coordinator.go          # Distributed operations
β”‚   β”‚   β”œβ”€β”€ quorum.go               # Quorum management
β”‚   β”‚   └── handoff.go              # Hinted handoff
β”‚   β”‚
β”‚   β”œβ”€β”€ ring/
β”‚   β”‚   β”œβ”€β”€ hash_ring.go            # Consistent hashing
β”‚   β”‚   └── vnode.go                # Virtual nodes
β”‚   β”‚
β”‚   β”œβ”€β”€ storage/
β”‚   β”‚   β”œβ”€β”€ engine.go               # Storage interface
β”‚   β”‚   β”œβ”€β”€ bitcask.go              # Bitcask implementation
β”‚   β”‚   β”œβ”€β”€ index.go                # In-memory index
β”‚   β”‚   └── bitcask_test.go         # Unit tests
β”‚   β”‚
β”‚   └── versioning/
β”‚       β”œβ”€β”€ vector_clock.go         # Vector clock operations
β”‚       └── resolver.go             # Conflict resolution
β”‚
β”œβ”€β”€ pkg/
β”‚   └── types/
β”‚       └── types.go                # Shared types & interfaces
β”‚
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ integration/
β”‚   β”‚   └── cluster_test.go         # Multi-node tests
β”‚   └── load/
β”‚       └── benchmark.go            # Load testing tool
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ start_cluster.sh            # Start 3-node cluster
β”‚   └── stop_cluster.sh             # Stop cluster
β”‚
β”œβ”€β”€ go.mod                          # Go module definition
β”œβ”€β”€ go.sum                          # Dependency checksums
β”œβ”€β”€ Makefile                        # Build automation
β”œβ”€β”€ config.example.json             # Example configuration
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

πŸ”¬ Technical Deep Dive

Consistent Hashing Algorithm

// Hash function: MurmurHash3 (64-bit)
func hash(key string) uint64 {
    h := murmur3.New64()
    h.Write([]byte(key))
    return h.Sum64()
}

// Virtual nodes for even distribution
for i := 0; i < virtualNodes; i++ {
    vnodeKey := fmt.Sprintf("%s#vnode%d", nodeID, i)
    ring.AddToken(hash(vnodeKey), nodeID)
}

// Key lookup: binary search for successor
func GetNode(key string) string {
    h := hash(key)
    idx := sort.Search(len(tokens), func(i int) bool {
        return tokens[i].Hash >= h
    })
    return tokens[idx % len(tokens)].NodeID
}

Quorum Mathematics

For a replication factor of N = 3:

Configuration Guarantees
W=2, R=2 Strong consistency (W + R > N)
W=1, R=1 Eventual consistency (faster, less safe)
W=3, R=1 Write-heavy workload optimization
W=1, R=3 Read-heavy workload optimization

Bitcask File Format

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CRC32     β”‚ Timestamp β”‚ Key Len β”‚ Value Len β”‚ Deleted β”‚   Key   β”‚  Value  β”‚
β”‚  (4 bytes) β”‚ (8 bytes) β”‚(4 bytes)β”‚ (4 bytes) β”‚(1 byte) β”‚(N bytes)β”‚(M bytes)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Gossip Protocol State Machine

         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                                     β”‚
         β–Ό                                     β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    5s timeout    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
    β”‚  ALIVE  │─────────────────►│ SUSPECT β”‚   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
         β–²                            β”‚        β”‚
         β”‚                            β”‚ 30s    β”‚
         β”‚                            β”‚timeout β”‚
         β”‚  Heartbeat                 β–Ό        β”‚
         β”‚  received             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
         └───────────────────────│  DEAD  β”‚β”€β”€β”€β”€β”˜
                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β”‚ Removed from
                                      β”‚ hash ring
                                      β–Ό

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone your fork
git clone https://github.com/YOUR_USERNAME/Distributed-Key-Value-Store-with-Tunable-Consistency.git
cd Distributed-Key-Value-Store-with-Tunable-Consistency

# Install dev dependencies
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

# Run linter
make lint

# Run tests before committing
make test-all

Code Style

  • Follow standard Go conventions
  • Run go fmt before committing
  • Add tests for new functionality
  • Update documentation as needed

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgments


Developed by Bhushan Asati

Made with ❀️ for distributed systems enthusiasts

⬆ Back to Top

About

A high-availability distributed key-value store built in Go. Implements Consistent Hashing for sharding, Tunable Consistency (Quorums), and Gossip Protocol for failure detection. Features a custom Bitcask-style storage engine with Write-Ahead Logging (WAL) for data durability. Modeled after Amazon Dynamo.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages