Lux: a Rust rewrite of Redis. 5.6x faster, ~1Mb docker image, MIT license

117 points mattyhogan 35 comments

I've been working on Lux, a multi-threaded Redis-compatible KV store written in Rust. It speaks RESP natively so every existing Redis client (ioredis, redis-py, go-redis, etc.) works with zero code changes.

Redis is single-threaded by design. Lux splits its keyspace across auto-tuned shards, each protected by a reader-writer lock. Multiple reads run in parallel with zero contention, writes only lock the specific shard being written to. Pipelined commands get sorted and batched by shard so you acquire each lock once instead of per-command.

The RESP parser is zero-copy (byte slices into the read buffer, no heap allocations until insertion). Shards are cache-line aligned to prevent false sharing. Common responses are pre-serialized as static byte slices.

Benchmarks against Redis 7, Valkey 9, and KeyDB using redis-benchmark (50 clients, 1M requests):

Pipeline Lux Redis Valkey KeyDB vs Redis
1 106K 110K 108K 68K 0.97x
16 1.49M 902K 745K 930K 1.65x
64 4.65M 1.50M 1.16M 1.41M 3.10x
128 7.19M 1.73M 1.30M 1.46M 4.16x
256 10.5M 1.88M 1.41M 1.35M 5.59x

The Docker image is 856KB on ARM and 1.36MB on x86 (scratch base, statically linked musl, LTO + panic=abort + strip). The whole thing is around 2,500 lines of Rust.

MIT licensed. Would love any feedback on the architecture or benchmarks.

https://github.com/lux-db/lux