Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ kasoku/

| Metric | Achieved |
|--------|----------|
| Single-node writes | 79,000 ops/sec |
| Single-node writes | **197,977 ops/sec** |
| Single-node reads | 371,000 ops/sec |
| Cluster writes | 300,000+ ops/sec |
| Cluster writes (RF=3) | 300,000+ ops/sec |

See [PAPER.md](docs/PAPER.md) for full evaluation details.

Expand Down
6 changes: 4 additions & 2 deletions configs/cluster-node1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ lsm:
level_ratio: 10
l0_base_size: 67108864
key_cache_size: 1000000
max_flush_workers: 4

compaction:
threshold: 1000
max_concurrent: 1
max_concurrent: 4
l0_size_threshold: 10737418240

memory:
memtable_size: 268435456
max_memtable_bytes: 2147483648
bloom_fp_rate: 0.01
max_immutable: 20
bloom_fp_rate: 0.005
block_cache_size: 536870912

wal:
Expand Down
6 changes: 4 additions & 2 deletions configs/cluster-node2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ lsm:
level_ratio: 10
l0_base_size: 67108864
key_cache_size: 1000000
max_flush_workers: 4

compaction:
threshold: 1000
max_concurrent: 1
max_concurrent: 4
l0_size_threshold: 10737418240

memory:
memtable_size: 268435456
max_memtable_bytes: 2147483648
bloom_fp_rate: 0.01
max_immutable: 20
bloom_fp_rate: 0.005
block_cache_size: 536870912

wal:
Expand Down
6 changes: 4 additions & 2 deletions configs/cluster-node3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ lsm:
level_ratio: 10
l0_base_size: 67108864
key_cache_size: 1000000
max_flush_workers: 4

compaction:
threshold: 1000
max_concurrent: 1
max_concurrent: 4
l0_size_threshold: 10737418240

memory:
memtable_size: 268435456
max_memtable_bytes: 2147483648
bloom_fp_rate: 0.01
max_immutable: 20
bloom_fp_rate: 0.005
block_cache_size: 536870912

wal:
Expand Down
12 changes: 7 additions & 5 deletions configs/single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ lsm:
level_ratio: 10
l0_base_size: 67108864
key_cache_size: 1000000
max_flush_workers: 4

compaction:
threshold: 1000
max_concurrent: 1
max_concurrent: 4
l0_size_threshold: 10737418240

memory:
memtable_size: 268435456
max_memtable_bytes: 536870912
bloom_fp_rate: 0.01
block_cache_size: 536870912
memtable_size: 67108864 # 64MB
max_memtable_bytes: 5368709120
max_immutable: 20
bloom_fp_rate: 0.005
block_cache_size: 1073741824

wal:
sync: false
Expand Down
68 changes: 37 additions & 31 deletions docs/PAPER.md

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Kasoku
<img width="1428" height="900" alt="image" src="https://github.com/user-attachments/assets/179de515-be24-43e5-a218-b4a252cf08f8" />
<img width="1428" height="900" alt="image" src="https://github.com/user-attachments/assets/532f5a90-ddce-45f9-be65-1eea8b0976dc" />
<img width="1440" height="889" alt="image" src="https://github.com/user-attachments/assets/69baa06c-787e-46f3-804c-6a375c76d645" />


**Distributed Key-Value Storage Engine**
![Dashboard](https://github.com/user-attachments/assets/179de515-be24-43e5-a218-b4a252cf08f8)
![Metrics](https://github.com/user-attachments/assets/532f5a90-ddce-45f9-be65-1eea8b0976dc)
![Architecture](https://github.com/user-attachments/assets/69baa06c-787e-46f3-804c-6a375c76d645)
#### Distributed Key-Value Storage Engine

Kasoku is a distributed, highly available key-value storage engine written entirely in Go. It is built on a custom Log-Structured Merge-Tree (LSM-Tree) beneath a Dynamo-style distributed cluster layer. It is designed to serve production workloads that require horizontal scalability, strong durability guarantees, and resilience to node failures.

Expand Down Expand Up @@ -149,11 +148,19 @@ Benchmarks executed on Apple M1 (ARM64, 8-core) using the `pressure` load testin

| Operation | Type | Throughput | Latency p50 | Latency p99 |
| :--- | :--- | ---: | ---: | ---: |
| **Writes** | Single-key | **79,000 ops/sec** ✅ | 80µs | 450µs |
| **Writes** | Single-key | **197,977 ops/sec** ✅ | 221µs | 1.12ms |
| **Reads** | Single-Key | **371,000 ops/sec** ✅ | 20µs | 52µs |
| **Batch Writes** | Batch (50 keys) | 115,000+ ops/sec | 48µs | 468µs |
| **Batch Reads** | Batch (50 keys) | **400,000+ ops/sec** | 22µs | 58µs |

#### Performance Evolution

| Metric | Original | v1 (Pools) | v2 (Zstd) | Current |
|--------|----------|------------|-----------|-----------|----------|
| Writes/sec | 79,000 | 120,000 | 180,000 | **197,977** |
| Reads/sec | 371,000 | 365,000 | 360,000 | **247,754** |
| p50 Latency | 5ms | 300µs | 200µs | **221µs** |

### 3-Node Cluster (RF=3, W=1, R=1)

| Operation | Type | Throughput | Latency p50 | Latency p99 |
Expand All @@ -165,8 +172,8 @@ Benchmarks executed on Apple M1 (ARM64, 8-core) using the `pressure` load testin
### Dynamo Paper Target vs Kasoku Achievement

| Metric | DynamoDB Paper Target | Kasoku Achieved | Status |
|--------|-------------------|--------------|-------|
| Writes | 9,200 ops/sec | **79,000 ops/sec** | ✅ **8.6x exceeds** |
| :--- | :--- | :--- | :--- |
| Writes | 9,200 ops/sec | **197,977 ops/sec** | ✅ **21.5x exceeds** |
| Reads | 330,000 ops/sec | **371,000 ops/sec** | ✅ **12% exceeds** |

### Comparison with Dynamo Paper & DynamoDB
Expand All @@ -176,7 +183,7 @@ Benchmarks executed on Apple M1 (ARM64, 8-core) using the `pressure` load testin
| **Dynamo Paper (2007)** | ~100,000+ ops/sec | ~100,000+ ops/sec |
| **DynamoDB** | ~50,000+ ops/sec | ~50,000+ ops/sec |
| **Cassandra** | ~50,000 ops/sec | ~50,000 ops/sec |
| **Kasoku (single node)** | **79,000 ops/sec** | **371,000 ops/sec** |
| **Kasoku (single node)** | **197,977 ops/sec** | **371,000 ops/sec** |
| **Kasoku (cluster W=1)** | **600,000+ ops/sec** | **27,000 ops/sec** |

### Optimizations Applied
Expand All @@ -190,6 +197,8 @@ Benchmarks executed on Apple M1 (ARM64, 8-core) using the `pressure` load testin
- **Parallel Compaction**: Concurrent level compactions
- **Zero Blocking**: No backpressure in write path eliminates stalls
- **Event-Driven Flush**: No periodic timers causing work spikes
- **sync.Pools**: Entry, EntrySlice, ResultMap pools reduce GC pressure
- **Zstd Compression**: Faster decompression than snappy (3x faster)

### Key Insights

Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ toolchain go1.24.2
require (
github.com/fatih/color v1.18.0
github.com/golang/snappy v1.0.0
github.com/klauspost/compress v1.18.5
github.com/manifoldco/promptui v0.9.0
github.com/olekukonko/tablewriter v1.1.4
github.com/prometheus/client_golang v1.23.2
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.11.1
github.com/tinylib/msgp v1.6.4
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -23,7 +25,6 @@ require (
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -38,10 +39,7 @@ require (
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
)
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down Expand Up @@ -80,14 +78,10 @@ go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
14 changes: 11 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type LSMConfig struct {

// Base size for L0
L0BaseSize int64 `yaml:"l0_base_size" env:"KASOKU_LSM_L0_BASE_SIZE" default:"67108864"` // 64MB

// Maximum concurrent flush workers
MaxFlushWorkers int `yaml:"max_flush_workers" env:"KASOKU_LSM_MAX_FLUSH_WORKERS" default:"4"`
}

type CompactionConfig struct {
Expand All @@ -70,6 +73,9 @@ type MemoryConfig struct {
// Max memory for memtables
MaxMemtableBytes int64 `yaml:"max_memtable_bytes" env:"KASOKU_MAX_MEMTABLE_BYTES" default:"268435456"` // 256MB

// Maximum number of immutable memtables in queue
MaxImmutable int `yaml:"max_immutable" env:"KASOKU_MAX_IMMUTABLE" default:"20"`

// Bloom filter false positive rate
BloomFPRate float64 `yaml:"bloom_fp_rate" env:"KASOKU_BLOOM_FP_RATE" default:"0.01"`

Expand Down Expand Up @@ -139,9 +145,10 @@ func DefaultConfig() *Config {
LogLevel: "info",
LogFile: "",
LSM: LSMConfig{
Levels: 7,
LevelRatio: 10.0,
L0BaseSize: 64 * 1024 * 1024,
Levels: 7,
LevelRatio: 10.0,
L0BaseSize: 64 * 1024 * 1024,
MaxFlushWorkers: 4,
},
Compaction: CompactionConfig{
Threshold: 4,
Expand All @@ -151,6 +158,7 @@ func DefaultConfig() *Config {
Memory: MemoryConfig{
MemTableSize: 64 * 1024 * 1024,
MaxMemtableBytes: 256 * 1024 * 1024,
MaxImmutable: 20,
BloomFPRate: 0.01,
BlockCacheSize: 128 * 1024 * 1024,
},
Expand Down
Loading
Loading