Free to read

Build your own Redis in Node.js, one short file at a time

Redis feels like a black box until you build a tiny version yourself. You start with a program that just listens on a port. By the end, the same program speaks the real Redis language, remembers data after a restart, and a backup machine quietly mirrors it. Pure standard library Node. No frameworks. No magic.

Still deciding? Ask first.

Message a mentor about fit, prerequisites, or where to start. Replies come on WhatsApp, usually within a day.

  • Curriculum fit, prerequisites, or where to start
  • Honest answer, no pressure to enroll

Taught by an engineer who has shipped this

  • ISO 27001

    Led the engineering work behind the certification of a regulated EU platform.

  • Series A platform

    Architected the case-management product that became the business a €11.6M round was raised on.

  • 3x faster deploys

    Cut time-to-deploy by migrating to Kubernetes on GCP with deploy-on-merge.

Build your own Redis in Node.js, one short .mjs file at a time. You will write a tiny server that listens on a port, then teach it the same language real Redis clients speak, then give it memory, then teach it to remember after a restart, then let many readers subscribe to one writer. By the end you will have a working stand-in for Redis you understand line by line. Node's single-threaded event loop replaces the threads and locks you would write in other languages, so the code stays small and easy to read.

Write your own Redis in Node.js, one short .mjs at a time. Sockets, the wire language, the store, expiry, persistence, fan-out, and a backup machine. Pure standard library.

What you'll ship

Real projects, not toy demos.

  • A TCP server with net.createServer and per-conn data event handlers
  • A Buffer + cursor RESP parser that returns null for incomplete frames
  • A Map-backed KV store with command dispatch (no locks needed)
  • EXPIRE / TTL with Date.now timestamps + active sweep via setInterval
  • AOF persistence with fs.createWriteStream and readFileSync replay
  • RDB snapshots using fs.writeFile + fs.rename, async BGSAVE
  • Pub/Sub with Map<channel, Set<conn>> and write fan-out
  • Master/replica replication via net.connect + SYNC + streaming
  • Graceful shutdown with process.on(SIGTERM) and a polling drain loop
  • An async worker-pool benchmark harness

What you'll learn

You finish able to:

  • Build a multi-client TCP server with net.createServer and per-connection data events
  • Parse the Redis wire format using Buffer slices and a cursor-based recursive decoder
  • Pick when single-threaded Node needs no locks and when it needs worker_threads
  • Implement TTLs that survive AOF replay using Date.now absolute timestamps
  • Snapshot in-memory state with fs.writeFile + fs.rename atomic-replace
  • Fan out pub/sub messages using a Map<channel, Set<conn>> and conn.write
  • Stream master/replica writes over the same RESP wire format we already speak
  • Drain in-flight clients gracefully on SIGTERM with server.close and a deadline timer

Curriculum

From net.createServer to your own Redis.

  1. 01

    Network and protocol

    net.createServer + Buffer-based RESP parser.

  2. 02

    Store and expiry

    Map + dispatch (no locks). Date.now TTLs with active sweep.

  3. 03

    Durability: AOF and RDB in Node

    fs.createWriteStream for AOF, fs.writeFile + fs.rename for RDB. Async fire-and-forget BGSAVE.

  4. 04

    Messaging and replication

    Map<channel, Set<conn>> pub/sub and SYNC + write streaming.

  5. 05

    Scaling: Graceful shutdown and benchmark

    process.on(SIGTERM) + server.close + drain loop. Then async worker-pool benchmark.

Who it's for

Is this for you?

Node developers

You write API handlers and middleware. You want a project that exercises net, fs, Buffer, async, and signal handling in one stack.

Engineers moving to Node

You know another language. You want to see how Node\u2019s single-threaded event-loop model compares on the same problem.

JavaScript engineers exploring backend

You only know Node through Express and frameworks. You want raw stdlib mastery.

FAQ

Common questions.

  • Do I need TypeScript?

    No. The workshop uses plain .mjs files. The exercises in step 2 walk through a TypeScript port if you want types.

  • How does it compare to the Python and Go siblings?

    Same architecture, different idioms. Node is single-threaded with an event loop; Python uses threads or selectors; Go uses goroutines. The course README compares all three.

  • Will my Node server beat real Redis?

    No. Node typically lands between Python and Go for this kind of workload. Real Redis is hand-tuned C. The capstone step explains where the remaining gap comes from.

  • Do I need any deps?

    None. Pure stdlib. Just Node 20+ for the node: import scheme and parseArgs.