展示HN:Lux – Rust语言的Redis替代方案。速度提升5.6倍,Docker镜像约1MB。
Show HN: Lux – Drop-in Redis replacement in Rust. 5.6x faster, ~1MB Docker image

原始链接: https://github.com/lux-db/lux

## Lux:更快的Redis替代方案 Lux是Redis的即插即用替代品,通过Rust构建的多线程分片架构,提供**3-5倍的性能提升**。它与现有的Redis客户端(ioredis、redis-py、go-redis等)保持完全兼容——**无需更改任何代码**,只需更新连接字符串即可。 与Redis的单线程设计不同,Lux利用所有可用核心,随着并发性和流水线深度的增加而高效扩展。基准测试表明,Lux在流水线深度为256时,可达到**每秒1050万次SET操作**,显著优于Redis。 Lux支持广泛的Redis命令(字符串、列表、哈希、集合、发布/订阅)和RESP协议。它轻量级(856KB Docker镜像),并提供持久化、身份验证和监控等功能。 **Lux Cloud** 提供托管服务,起价为每月5美元,提供1GB实例——在同一价格下提供Redis Cloud的4倍内存。 Lux采用**MIT许可**,确保免受限制性许可变更的影响。

## Lux:一种新型Redis替代方案 一种名为Lux的新型、基于Rust的内存数据存储正在受到关注,它可能成为Redis的直接替代品。Lux由mattyhogan创建,拥有显著的性能提升——速度快5.6倍——以及惊人的1MB Docker镜像大小。 Lux通过分片、并发设计,利用读写锁和零拷贝解析,解决了Redis的单线程架构问题。它保持了Redis协议(RESP)兼容性,这意味着现有的客户端应该可以无缝工作。项目README中提供了与Redis、Valkey和KeyDB的基准测试。 最初的反应褒贬不一。虽然Lux因其速度和简洁的设计而受到赞扬,但人们也对其非常近期的创建(只有几个提交)、缺乏全面的测试以及对Redis命令完全兼容性的问题表示担忧。开发者欢迎提问,并在luxdb.dev提供托管服务。
相关文章

原文

Lux

A drop-in Redis replacement. 3-5x faster.
Multi-threaded. Written in Rust. MIT licensed forever.

Lux Cloud · Benchmarks · Architecture


Redis is single-threaded by design. Every command runs on one core. Lux takes the opposite approach: a sharded concurrent architecture built in Rust that safely uses all your cores. Change your connection string. Everything else stays the same.

Works with every Redis client -- ioredis, redis-py, go-redis, Jedis, redis-rb. Zero code changes.

redis-benchmark, 50 clients, 1M requests per test. All competitors on the same machine.

Pipeline Lux Redis 7 Valkey 9 KeyDB Lux 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

At pipeline depth 256, Lux hits 10.5 million SET ops/sec. That's 5.6x faster than Redis. The gap grows with core count and pipeline depth because Lux's shard batching and multi-threading scale with concurrency while Redis hits a single-core ceiling.

Don't want to manage infrastructure? Lux Cloud is managed Lux hosting.

  • $5/mo per instance, 1GB memory
  • 4x more memory than Redis Cloud at the same price
  • Deploy in seconds, connect with any Redis client
  • Persistence, monitoring, and web console included
  • 80+ Redis commands -- strings, lists, hashes, sets, pub/sub
  • RESP protocol -- drop-in compatible with every Redis client
  • Multi-threaded -- auto-tuned shards, parking_lot RwLocks, tokio async runtime
  • Zero-copy parser -- RESP arguments are byte slices into the read buffer
  • Pipeline batching -- commands grouped by shard, one lock acquisition per batch
  • Persistence -- automatic snapshots, configurable interval
  • Auth -- password authentication via LUX_PASSWORD
  • Pub/Sub -- SUBSCRIBE, UNSUBSCRIBE, PUBLISH
  • TTL support -- EX, PX, EXPIRE, PEXPIRE, PERSIST, TTL, PTTL
  • 856KB Docker image -- the entire database fits in under 1MB. Redis is 30MB. Dragonfly is 180MB.
  • MIT licensed -- no license rug-pulls, unlike Redis (RSALv2/SSPL)
cargo build --release
./target/release/lux

Lux starts on 0.0.0.0:6379 by default. Connect with any Redis client:

redis-cli
> SET hello world
OK
> GET hello
"world"
docker run -d -p 6379:6379 ghcr.io/lux-db/lux:latest
Variable Default Description
LUX_PORT 6379 TCP port
LUX_PASSWORD (none) Enable AUTH
LUX_DATA_DIR . Snapshot directory
LUX_SAVE_INTERVAL 60 Snapshot interval in seconds (0 to disable)
LUX_SHARDS auto Shard count (default: num_cpus * 16)
LUX_RESTRICTED (none) Set to 1 to disable KEYS, FLUSHALL, FLUSHDB
import Redis from "ioredis"

const redis = new Redis("redis://localhost:6379")
await redis.set("hello", "world")
console.log(await redis.get("hello")) // "world"
import redis

r = redis.Redis(host="localhost", port=6379)
r.set("hello", "world")
print(r.get("hello"))  # b"world"
import "github.com/redis/go-redis/v9"

rdb := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
rdb.Set(ctx, "hello", "world", 0)

Strings: SET GET SETNX SETEX PSETEX GETSET MGET MSET STRLEN APPEND INCR DECR INCRBY DECRBY

Keys: DEL EXISTS KEYS SCAN TYPE RENAME TTL PTTL EXPIRE PEXPIRE PERSIST DBSIZE FLUSHDB FLUSHALL

Lists: LPUSH RPUSH LPOP RPOP LLEN LRANGE LINDEX

Hashes: HSET HMSET HGET HMGET HDEL HGETALL HKEYS HVALS HLEN HEXISTS HINCRBY

Sets: SADD SREM SMEMBERS SISMEMBER SCARD SUNION SINTER SDIFF

Pub/Sub: PUBLISH SUBSCRIBE UNSUBSCRIBE

Server: PING ECHO INFO SAVE BGSAVE LASTSAVE AUTH CONFIG CLIENT SELECT COMMAND DUMP RESTORE

Client connections (tokio tasks)
        |
   Zero-Copy RESP Parser (byte slices, no allocations)
        |
   Pipeline Batching (group by shard, sort, batch execute)
        |
   Command Dispatch (byte-level matching, no string conversion)
        |
   Sharded Store (auto-tuned RwLock shards, hashbrown raw_entry)
        |
   FNV Hash -> Shard Selection (pre-computed, reused for HashMap lookup)

Read the full deep dive at luxdb.dev/architecture.

MIT

联系我们 contact @ memedata.com