BigDB is a Go-based storage engine inspired by Bigtable and LSM-tree design principles. It implements a durable write path, in-memory memtable, immutable SSTables, background flush, leveled compaction, crash recovery, corruption detection, and telemetry.
BigDB is designed to demonstrate the core mechanics of a production-style storage engine, including:
- write-ahead logging for durability
- in-memory buffering through a memtable
- immutable SSTable creation on flush
- leveled compaction for efficient space reclamation
- crash recovery through WAL replay
- checksum-based corruption detection
- observability through telemetry events
- benchmarking and profiling for performance analysis
The engine follows a standard LSM-style flow:
Client write → WAL append → Memtable update → background flush → SSTable creation → leveled compaction → WAL replay on recovery
Reads are resolved in the following order:
- Memtable
- Recently flushed state and cached SSTables
- SSTables, searched in level order
- Tombstones to preserve delete semantics
Writes are first appended to the WAL and then applied to the memtable. This ensures durability even if the process exits unexpectedly before a flush occurs.
- WAL-first durability with checksum validation
- Memtable for fast in-memory reads and writes
- SSTable caching to keep opened tables in memory and avoid repeated reloads
- SSTable flush path with sparse indexing and Bloom filters
- Leveled compaction with duplicate elimination and tombstone handling
- Crash recovery through WAL replay
- Corruption detection for WAL and SSTable files
- Telemetry for runtime visibility
- Benchmarks and profiling to measure real performance characteristics
- Go
- Standard library packages for concurrency, file I/O, timing, and filesystem operations
- Custom packages for WAL, memtable, SSTable, compaction, recovery, and telemetry
- Testing and profiling tools:
go testgo test -racego test -benchgo tool pprof
cmd/db— CLI entrypointinternal/db— core engine orchestrationinternal/wal— append, replay, rotation, checkpointing, checksum handlinginternal/memtable— in-memory state and snapshot supportinternal/sstable— SSTable read/write, sparse index, checksum validationinternal/compaction— SSTable merge logicinternal/recovery— WAL replay into memtableinternal/telemetry— event and snapshot types
The project can be built and shared as a container image.
docker build -t bigdb .
docker run --rm -v bigdb-data:/data bigdb -put-key user:1 -put-value alicePublished image:
- GHCR:
ghcr.io/mayank-1007/bigdb:latest - Package page:
https://github.com/users/mayank-1007/packages/container/bigdb
Can be directly pulled with:
docker pull ghcr.io/mayank-1007/bigdb:latestgo run ./cmd/db -data-dir ./data -put-key user:1 -put-value alice
go run ./cmd/db -data-dir ./data -get-key user:1
go run ./cmd/db -data-dir ./data -del-key user:1
go run ./cmd/db -data-dir ./data -compact