Introduction
SSDB is a high-performance NoSQL database written in C++ that provides Redis-compatible commands backed by LevelDB or RocksDB for persistent storage. It is designed for datasets too large to fit in memory, offering disk-based storage with performance close to Redis for common operations.
What SSDB Does
- Stores key-value, hash, sorted set, list, and queue data structures
- Supports a large subset of Redis commands for easy migration
- Persists data to disk using LevelDB or RocksDB storage engines
- Handles datasets far exceeding available RAM via disk-backed storage
- Provides master-slave and master-master replication
Architecture Overview
SSDB uses a single-threaded event loop for network I/O and dispatches storage operations to LevelDB or RocksDB. Data structures are encoded into key-value pairs in the underlying LSM-tree engine. Write-ahead logging ensures durability, and background compaction keeps read performance stable. The replication system streams binlog entries between nodes for high availability.
Self-Hosting & Configuration
- Build from source with make on Linux or macOS
- Edit ssdb.conf to set the listen port, data directory, and cache size
- Configure LevelDB cache and block size for your workload
- Set up master-slave replication by adding slaveof directives
- Monitor with the built-in info command or compatible Redis tools
Key Features
- Redis-compatible API supporting most common data structure commands
- Disk-based storage handling hundreds of GB without memory constraints
- Master-slave and master-master replication for high availability
- LevelDB and RocksDB backend options for tuning write amplification
- Clients available in most programming languages (Python, Go, Java, PHP, Node.js)
Comparison with Similar Tools
- Redis — in-memory only (without persistence add-ons); SSDB stores data on disk for larger-than-RAM datasets
- KeyDB — multithreaded Redis fork still memory-bound; SSDB is disk-native
- Pika — another Redis-on-disk alternative using RocksDB; SSDB offers a simpler, lighter deployment
- DragonflyDB — modern in-memory store; SSDB targets scenarios where data must persist on disk
FAQ
Q: Can I use existing Redis clients with SSDB? A: Yes, SSDB supports the Redis wire protocol for most commands. Standard Redis clients in Python, Go, Java, and other languages work with minor adjustments.
Q: How does performance compare to Redis? A: For datasets that fit in the OS page cache, SSDB approaches Redis speeds. For larger datasets, disk I/O becomes the bottleneck but remains fast thanks to LevelDB optimizations.
Q: Does SSDB support clustering? A: SSDB supports master-slave and master-master replication. Application-level sharding is used for horizontal scaling across multiple instances.
Q: What happens if the server crashes? A: LevelDB provides write-ahead logging. On restart, SSDB recovers committed data automatically from the WAL and SST files.