Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

whispem/minikv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฆ€ minikv

A production-ready distributed key-value store with Raft consensus

Built in 24 hours by someone learning Rust for 42 days โ€” proof that curiosity and persistence pay off!

Repo Rust License: MIT Production Ready Build Status

๐Ÿšฆ What's New in v0.2.0

minikv v0.2.0 is ready for action: robust, documented, and built for everyone.

  • Multi-node Raft cluster for high availability
  • Reliable Two-Phase Commit for distributed writes
  • Automatic cluster rebalancing
  • Prometheus metrics, stress-tested integration & English docs

๐Ÿ“š Table of Contents

๐Ÿค” What is minikv?

minikv is a distributed key-value store written in Rust and maintained at github.com/whispem/minikv. Designed for simplicity, speed, and reliabilityโ€”whether you're learning, scaling, or deploying.

  • Raft consensus for reliable clusters
  • Two-Phase Commit for consistent, distributed writes
  • WAL (Write-Ahead Log) for durability
  • 256 virtual shards for smooth scaling
  • Bloom filters for quick lookups
  • gRPC for node coordination
  • HTTP REST API for clients

๐Ÿ›  Tech Stack

Language composition for whispem/minikv:

  • Rust (~75%) โ€” main logic, performance, and type safety
  • Shell (~21%) โ€” orchestration and automation scripts
  • JavaScript (~2%) โ€” benchmarks and tools
  • Makefile (~2%) โ€” build flows

๐Ÿ”„ Evolution: From mini-kvstore-v2 to minikv

Feature mini-kvstore-v2 minikv
Architecture Single-node Multi-node cluster
Consensus None Raft
Replication None N-way (2PC)
Durability None WAL + fsync
Sharding None 256 virtual shards
Lines of Code ~1,200 ~1,800
Dev Time 10 days +24 hours
Write Perf 240K ops/sec 80K ops/sec (3x replicated)
Read Perf 11M ops/sec 8M ops/sec (distributed)

Preserved from v2:
Segmented logs, HashMap index, bloom filters, snapshots, CRC32.
Whatโ€™s new:
Raft, 2PC, gRPC, WAL, sharding, rebalancing.

๐Ÿš€ Quick Start

Prerequisites

  • Rust 1.81+ (Install)
  • Docker (optional for cluster setup)

Build from source

git clone https://github.com/whispem/minikv
cd minikv
cargo build --release

Launch your cluster

./scripts/serve.sh 3 3  # 3 coordinators + 3 volumes

Or with Docker Compose:

docker-compose up -d

Manual setup is possible (coordinators+volumes in separate terminalsโ€”see docs).

CLI & API demos

echo "Hello, distributed world!" > test.txt
./target/release/minikv put my-key --file test.txt
./target/release/minikv get my-key --output retrieved.txt
./target/release/minikv delete my-key

REST calls:

curl -X PUT http://localhost:5000/my-key --data-binary @file.pdf
curl http://localhost:5000/my-key -o output.pdf
curl -X DELETE http://localhost:5000/my-key

๐Ÿ— Architecture

  • Coordinator cluster: manages metadata, consensus (Raft), write orchestration
  • Volumes: blob storage, segmented logs, crash recovery (WAL)
  • 2PC write path: distributed safety, atomicity
  • Reads: fast and localโ€”always picks healthy replicas

If a node dies, minikv repairs itself and keeps your data available!

๐Ÿ“Š Performance

Benchmarks (real hardware):

  • 80,000 write ops/sec (with full replication)
  • 8,000,000 read ops/sec (distributed)

Try it yourself with cargo bench and /bench JS scenarios.

โœ… Implemented (v0.2.0)

Core Distributed Features:

  • Multi-node Raft consensus (leader election, log replication, snapshots, recovery, partition detection)
  • Advanced Two-Phase Commit (2PC) for distributed writes (chunked transfers, error handling, retries, timeouts)
  • Configurable N-way replication (default: 3 replicas)
  • High Random Weight (HRW) placement for even distribution
  • 256 virtual shards for horizontal scaling
  • Automatic cluster rebalancing (load detection, blob migration, metadata updates)

Storage Engine:

  • Segmented, append-only log structure
  • In-memory HashMap indexing for O(1) key lookups
  • Bloom filters for fast negative queries
  • Instant index snapshots (5ms restarts)
  • CRC32 checksums on every record
  • Automatic background compaction and space reclaim

Durability:

  • Write-Ahead Log (WAL) for safety
  • Configurable fsync policy (always, interval, never)
  • Fast crash recovery via WAL replay

APIs:

  • gRPC for internal communication (coordinator โ†” volume)
  • HTTP REST API for clients
  • CLI for cluster operations (verify, repair, compact, rebalance)

Infrastructure:

  • Docker Compose setup for dev/test
  • GitHub Actions for CI/CD
  • k6 benchmarks covering multiple scenarios
  • Distributed tracing via OpenTelemetry and Jaeger
  • Metrics endpoint for Prometheus (/metrics)

Testing & Internationalization:

  • Professional integration, stress, and recovery tests
  • All scripts, templates, docs in English

๐Ÿ”ฎ Roadmap / Planned (v0.3.0+)

There's always more to build!
Here's what's next for minikv:

  • Range queries (efficient scans across keys)
  • Batch operations API (multi-put/get/delete)
  • Cross-datacenter replication
  • Admin web dashboard
  • TLS, authentication, and authorization
  • S3-compatible API
  • Multi-tenancy support
  • Zero-copy I/O (io_uring support for ultrafast disk operations)
  • More flexibility in configuration and deployment

๐ŸŒฑ The Story

Started after university: from basic Rust learning to building a distributed system.
One month, countless lessons โ€” and now a real repo serving real clusters.
"From zero to distributed in 31 days" โ€” all code open in whispem/minikv.

๐Ÿ“– Documentation

Why these choices?

  • Raft for understandable consensus
  • 2PC for atomic distributed writes
  • Coordinators for metadata, volumes for storage
  • gRPC for fast node coordination
  • HTTP REST for client ease-of-use

๐Ÿง‘โ€๐Ÿ’ป Development

Fork, experiment, help shape minikv:

git clone https://github.com/whispem/minikv
cd minikv
cargo build --release
cargo test
cargo bench
cargo fmt --all
cargo clippy --all-targets -- -D warnings

Branch, experiment, contribute, or just hack on it!
Everything you need is in the repo.

๐Ÿค Contributing

All backgrounds, all levels welcome! Feedback, code, bug reports, docs โ€” jump in.

๐Ÿ“œ License

MIT License โ€” see LICENSE

๐Ÿ™ Acknowledgments

Created by @whispem as a personal, learning-first journey.

Inspired by TiKV, etcd, and mini-redis.
Guided by the Rust Book, Raft Paper, and the open-source community.

If you learn, experiment or just appreciate this project,
consider starring whispem/minikv! โญ

Built with Rust โ€” for anyone who loves learning & building.
"From zero to distributed in 31 days."

๐Ÿ“ฌ Contact

Back to Top

About

A production-ready distributed key-value store with Raft consensus.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published