Docs Persistence

Persistence

RDB snapshots + AOF append-only file — Redis-compatible persistence with near-zero overhead

SoliKV supports two complementary persistence mechanisms, matching Redis defaults. AOF is enabled by default with appendfsync everysec, losing at most ~1 second of data on crash. RDB snapshots are saved every 5 minutes as a safety net.

How It Works

AOF (Append-Only File)

  • 1. Every write command is RESP-serialized on the caller thread
  • 2. Serialized bytes are sent through a 256K bounded channel (lock-free)
  • 3. Background task batch-drains the channel into a 64KB BufWriter
  • 4. fsync is called per the configured policy (always/everysec/no)
File: data/appendonly.aof (RESP format)

RDB (Snapshots)

  • 1. Full point-in-time snapshot of all data per shard
  • 2. Background task saves every 300 seconds
  • 3. Atomic write via temp file + rename (crash-safe)
  • 4. Final snapshot saved on graceful shutdown (CTRL-C)
Files: data/dump-0.rdb, data/dump-1.rdb, ...

Startup Sequence

  1. 1
    Load RDB snapshots — Each shard's RDB file is loaded to restore the base state
  2. 2
    Replay AOF — Commands from the AOF are replayed on top of the RDB state to bring data up to date
  3. 3
    Open AOF writer — New write commands start being logged to the AOF
  4. 4
    Start serving — RESP and REST servers begin accepting connections

Fsync Policies

PolicyDurabilityPerformanceUse case
always Every write fsynced Slowest Maximum durability
everysec Fsync every 1 second Near-zero overhead Default. Lose at most ~1s on crash
no OS decides when to flush Fastest Maximum performance, data at risk

Configuration

Terminal
# Default: AOF enabled with everysec fsync
./solikv
# Custom data directory and fsync policy
./solikv --dir /var/data/solikv --appendfsync always
# Disable AOF (RDB snapshots only)
./solikv --appendonly false
# Custom RDB filename prefix
./solikv --dbfilename mydb
# Creates: data/mydb-0.rdb, data/mydb-1.rdb, ...

Persistence Commands

CommandSyntaxDescription
SAVESAVESynchronous RDB save (blocks until complete)
BGSAVEBGSAVEBackground RDB save
BGREWRITEAOFBGREWRITEAOFRewrite AOF from current state (compaction)

Lock-Free AOF Performance

SoliKV's AOF uses a channel-based architecture that eliminates mutex contention on the hot path. Write commands are RESP-serialized on the caller thread and sent through a bounded channel to a dedicated I/O task.

~2-3%
AOF overhead on writes
256K
channel buffer capacity
64KB
BufWriter buffer size

Migrating from Redis

SoliKV can import standard Redis dump.rdb snapshot files at startup. This lets you migrate from Redis without re-inserting all your data.

Terminal
# 1. Generate a dump on your Redis instance
redis-cli BGSAVE
cp /var/lib/redis/dump.rdb /tmp/dump.rdb
# 2. Import into SoliKV
./solikv --import-redis-rdb /tmp/dump.rdb
Parsing Redis RDB version 11
Redis RDB import complete: RDB v11: 4821 keys imported, 0 skipped, 12 expired, 1 database(s)
# 3. Verify your data
redis-cli DBSIZE
(integer) 4821

Supported Types

  • Strings
  • Lists (plain, ziplist, quicklist, quicklist v2)
  • Sets (plain, intset, listpack)
  • Sorted Sets (plain, ziplist, listpack, binary scores)
  • Hashes (plain, ziplist, listpack)
  • LZF compressed values
  • Key expiry (absolute timestamps, ms precision)

Skipped (with warning)

  • Streams
  • Modules
  • Hash with per-field expiry (Redis 7.4+)

Unsupported keys are skipped and logged. All other keys are imported normally.

Multi-database RDB files: If your Redis instance uses multiple databases (DB 0, DB 1, ...), all keys are flattened into SoliKV's single namespace. Already-expired keys are automatically filtered out during import.

File Layout

data/
appendonly.aof # AOF log (RESP format)
dump-0.rdb # RDB snapshot for shard 0
dump-1.rdb # RDB snapshot for shard 1
dump-2.rdb # RDB snapshot for shard 2
... # One per shard (auto-detected from --shards)