Overview of SSDB
SSDB is a NoSQL database similar to Redis but designed for disk-based storage rather than in-memory operations. This makes it more cost-effective for applications where high-speed access is not critical. Unlike Redis, which stores all data in RAM, SSDB leverages disk space for persistence, enabling easier scalability at lower infrastructure costs. Performance benchmarks show that while SSDB may not match Redis in raw speed, it offers a compelling trade-off between performance and resource efficiency.
One notable behavior in SSDB is deferred disk space reclamation: when data is deleted, the space isn't immediately freed. Instead, cleanup occurs during background compaction. To force immediate space release, use the compact command—but be aware this can cause temporary performance degradation due to its I/O-intensive nature. A recommended practice is to schedule periodic compaction via cron jobs, such as nightly execution during off-peak hours.
Installation Steps
To install SSDB version 1.8.2:
cd /opt/modules/download
sudo wget https://github.com/ideawu/ssdb/archive/1.8.2.tar.gz
sudo tar zxvf 1.8.2.tar.gz
cd ssdb-1.8.2
sudo mkdir /opt/modules/ssdb
sudo make install PREFIX=/opt/modules/ssdb
Note: The installation process requires compilation before copying binaries. Skipping make will result in missing ssdb-server.
Starting, Stopping, and Restarting SSDB
By default, SSDB runs on port 8888. It's common to change this to avoid conflicts—6399 is often used instead. Update the configuration file accordingly.
Start SSDB:
sudo /opt/modules/ssdb/ssdb-server -d /opt/modules/ssdb/ssdb.conf
Check if the service is running:
sudo netstat -anp | grep 6399
Stop SSDB:
sudo /opt/modules/ssdb/ssdb-server -d /opt/modules/ssdb/ssdb.conf -s stop
Restart SSDB:
sudo /opt/modules/ssdb/ssdb-server -d /opt/modules/ssdb/ssdb.conf -s restart
Connect using the CLI tool:
sudo /opt/modules/ssdb/ssdb-cli -h 127.0.0.1 -p 6399
Once connected, run info to verify status:
ssdb 127.0.0.1:6399> info
version
1.8.2
links
1
total_calls
3
dbsize
0
binlogs
capacity : 10000000
min_seq : 0
max_seq : 0
key_range.kv
"" - ""
key_range.hash
"" - ""
key_range.zset
"" - ""
key_range.list
"" - ""
leveldb.stats
Compactions
Level Files Size(MB) Time(sec) Read(MB) Write(MB)
--------------------------------------------------
21 result(s) (0.000 sec)
Using SSDB: Data Types and Querying Keys
SSDB supports four data types: string (s), list (q), hash (h), and sorted set (z). Unlike Redis, there is no single command like keys to retrieve all keys across types. Instead, each type has its own query command:
keys: for string keysqlist: for list keyshlist: for hash keyszlist: for sorted set keys
Each command accepts three arguments: start prefix, end prefix, and limit count. Example usage:
ssdb 127.0.0.1:6399> set yes hello
ok
(0.000 sec)
ssdb 127.0.0.1:6399> keys "" "" 10
key
-----------------
yes
1 result(s) (0.000 sec)
ssdb 127.0.0.1:6399> set language go
ok
(0.000 sec)
ssdb 127.0.0.1:6399> keys "" "" 10
key
-----------------
language
yes
2 result(s) (0.000 sec)
ssdb 127.0.0.1:6399> keys "h" "m" 10
key
-----------------
language
1 result(s) (0.000 sec)
The first two parameters define the key range (e.g., "h" to "m" includes keys starting with letters h through m). Use empty strings to skip filtering. The third parameter limits the number of returned keys.
Common Installation Issues
Issue 1: cp: cannot stat ssdb-server: No such file or directory
This error occurs during make install when the binary ssdb-server is not found. The root cause is skipping the make step before make install. Even though the source directory contains the code, the executable is only built after running make. If you specify a custom PREFIX, ensure that make completes successfully before attempting installaiton.
Solution: Avoid specifying PREFIX initially. Run sudo make install directly without setting a custom path. Once successful, you can manually move files or rebuild with PREFIX later.
Issue 2: Failed Build Due to Missing Dependencies
Some users report failures related to Snappy or Jemalloc during build time. Although configuring and building these dependencies manually (in deps/snappy-1.1.0 and deps/jemalloc-3.3.1) is suggested, it does not always resolve the issue.
Root Cause: The problem is not dependency compilation but missing make execution prior to make install. The ssdb-server binary must be comipled first.
Final Fix: Rebuild from scratch without a custom PREFIX:
sudo make install
After success, optionally copy the installed files to /opt/modules/ssdb using cp or reconfigure with PREFIX after confirming the binary exists.
Avoiding PREFIX during initial setup ensures that the build process completes correctly and prevents confusion around missing executables.