
I built a Redis-compatible in-memory database in C that shows competitive performance against Dragonfly
Hi everyone,
I’ve been working on Freakv, a Redis-compatible in-memory key-value store written in C.
The project originally started as a university learning project because I wanted to deeply understand how high-performance systems are built internally: sharding, memory layout, lock avoidance, networking, persistence, and cross-thread coordination.
At the same time, I also wanted to build something serious enough to put on my CV while preparing for backend/systems engineering roles.
FreakV is built around:
- shared-nothing sharding architecture
- custom slab-style memory allocation
- asynchronous shard communication using SPSC queues
- zero-lock hot paths for normal single-shard operations
- zero-copy reply path
- TTL expiration + LRU eviction
- snapshot persistence without relying on fork()
- async two-phase MSET transaction protocol with cross-shard coordination
The server speaks Redis RESP2, so standard Redis clients work directly (redis-cli, redis-py, ioredis, Jedis, etc.).
I benchmarked Freakv against Dragonfly v1.25.2 on identical AWS hardware (c6in.16xlarge, 32 worker threads).
Some results:
SET — pipeline 10
memtier_benchmark -s $SERVER --ratio 1:0 -t 60 -c 20 -n 2000000 \
--distinct-client-seed --hide-histogram --pipeline=10 \
--print-percentiles=50,99,99.9,100
- Freakv: 13.6M ops/sec
- Dragonfly: 10.1M ops/sec
GET — pipeline 10
- Freakv: 12.3M ops/sec
- Dragonfly: 9.7M ops/sec
Additional SET stress run
memtier_benchmark -s $SERVER --ratio 1:0 -t 32 -c 60 -n 200000 \
--distinct-client-seed --hide-histogram \
--print-percentiles=50,99,99.9,100
- Freakv: 6.08M ops/sec @ 0.390 ms avg latency
- Dragonfly: 5.33M ops/sec @ 0.428 ms avg latency
Pipeline 10:
- Freakv: 13.7M ops/sec @ 1.637 ms avg latency
- Dragonfly: 9.4M ops/sec @ 2.261 ms avg latency
Even with snapshots enabled every 10 seconds, FreakV still sustained: 10.7M SET ops/sec
To be clear: Dragonfly is a far more mature production system with replication, richer data structures, cluster support, and many years of engineering behind it. Freakv currently only supports a Redis-compatible string subset.
So this isn’t meant as “Freakv beats Dragonfly overall”. The comparison is intentionally narrow: raw GET/SET throughput and latency on string workloads.
Still, as a learning-focused project written from scratch in C, I’m honestly pretty happy with how far it got.
As for AI usage: I used AI extensively during development, mainly as a learning/reference and acceleration tool.
I used it to speed up implementation of more straightforward components, for example RESP handling/parsing, boilerplate generation, code tracing, and iteration during debugging sessions.
The important part is that the architecture, systems design, profiling workflow, benchmarking methodology, bottleneck isolation, and debugging direction came from me, and a lot of the sensitive parts still required manual coding and iteration from my side.
Would love feedback from people working in databases, distributed systems, or low-level performance engineering.
Here is the repo: hphucp/freakv