Skip to content

Latest commit

 

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-performance in-memory datastore in Rust(1)

Rust Event Driven Zero Copy No Alloc

no ai. just docs, articles, code, and time.

RedrumDB is an in-memory datastore implemented in Rust.

The project focuses on building core components from scratch to better understand the design and performance characteristics of systems like Redis.

Features

  • key-value store (strings, lists, streams)
  • RESP protocol support
  • pub/sub
  • blocking operations (BLPOP)
  • key expiries
  • non-blocking I/O

Architecture

The server runs on a single-threaded, event-driven loop using mio, with slab-based connection management and non-blocking I/O.

Requests are parsed using a low-copy RESP parser, decoding command names and arguments directly from the connection buffer before dispatch.

Core components:

  • event loop + connections

    • mio-based loop with explicit readable/writable interest switching
    • slab + token model for stable connection indexing
    • backpressure-aware writes with per-connection output buffers
  • command execution

    • command dispatch table for normalized O(1)-style handler lookup
    • centralized handling of pub/sub mode constraints
  • memory + data model

    • in-memory keyspace with typed values (string, list, stream)
    • shared key storage using Arc<[u8]> to reduce duplication
  • scheduling + time

    • expiry engine using a min-heap (BinaryHeap<Reverse<Instant>>)
    • incremental cleanup bounded per loop to avoid latency spikes
  • blocking + async behavior

    • blocking list operations (BLPOP) with per-key wait queues
    • timeout scheduling integrated into the main event loop
  • streams

    • custom listpack implementation for compact storage
    • radix tree with prefix compression for ordered indexing
    • Redis-like stream ID semantics (*, ms-*, explicit IDs)

Design prioritizes predictable latency, minimal allocations, and explicit control over execution.

running

git clone https://github.com/thedevyashsaini/redrumdb
cd redrumdb
cargo run

Connect using:

redis-cli -p 6379

About

A high performance in-memory datastore in Rust

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages