Back to projects

distributed-cache

shipped

A Redis-compatible distributed cache built in Rust with Tokio, consistent hashing, and cluster replication.

·#systems#rust
RustTokiogRPC
const{Fragment:e,jsx:n,jsxs:t}=arguments[0];function _createMdxContent(r){const o={code:"code",p:"p",...r.components};return t(e,{children:[n(o.p,{children:"This started as a learning project to understand how Redis actually works under the hood — not the wire protocol in isolation, but the harder problems: sharding, replication, failover, and keeping latency predictable under load."}),"\n",t(o.p,{children:["The core is a Tokio-based async runtime that speaks the RESP protocol, so existing ",n(o.code,{children:"redis-cli"})," and most client libraries work without modification. Keys are distributed across nodes using a consistent hash ring, which makes adding or removing a node cheap instead of rehashing the entire keyspace."]}),"\n",n(o.p,{children:"For replication, each shard has a primary and one or more replicas. Writes go to the primary and are streamed via an append-only log; reads can hit any replica. The cluster membership layer uses a gossip protocol, so failure detection is decentralized and nodes converge on the same view of the cluster within a bounded number of rounds."}),"\n",n(o.p,{children:"The interesting engineering work was in the details: pipelining commands to amortize syscall overhead, bounding memory with an LRU + TTL eviction policy, and making sure the gossip layer doesn't drown out real traffic during rebalancing."}),"\n",n(o.p,{children:"It's not production-grade — no persistence, no cross-shard transactions — but it taught me more about distributed systems in a few months than years of consuming them as a black box."})]})}return{default:function(e={}){const{wrapper:t}=e.components||{};return t?n(t,{...e,children:n(_createMdxContent,{...e})}):_createMdxContent(e)}};