Khushal Agrawal

Databases / active

Redis Clone

A Redis-compatible Rust server with RESP parsing, async TCP networking, pub/sub, sorted sets, streams, geospatial commands, and benchmarked performance near Redis on supported workloads.

Architecture Overview

The Redis clone is built as a TCP server that accepts RESP-encoded commands, parses requests into command frames, executes them against an in-memory store, and writes RESP responses back to clients.

The implementation emphasizes a small systems surface: async Rust for concurrency, event-driven I/O for connection handling, explicit command dispatch, and benchmarkable hot paths.

Technical Challenges

  • RESP protocol parsing and serialization
  • connection state management over TCP
  • pub/sub channel fan-out
  • sorted set and geospatial side indexes
  • pipelined benchmark design against Redis
  • command execution without unnecessary shared-state complexity
  • keeping the implementation readable while preserving systems-level control

Benchmarks

I benchmarked supported workloads against Redis 8.6.2 on local TCP loopback. After profiling and removing pathological scans in sorted-set and geospatial operations, the clone reaches roughly Redis-class throughput on several supported microbenchmarks, with the blog post documenting both the numbers and the limitations.

Lessons Learned

Redis-style systems are valuable because the boundary is crisp: parse a wire protocol, maintain predictable in-memory state, make the hot path short, and let profiling expose where the data structures are wrong.

Tools

Rust, Tokio, Mio, Async-std