Free to read

Build your own Redis in Python, 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. Every line is plain Python you can read in one sitting. 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 Python, starting from a blank file. 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. Each step is one short Python file you can read in one sitting, and the difference between any two steps is the new idea you just learned.

Write your own Redis in Python, one short file at a time. Sockets, the wire language, the store, expiry, persistence, fan-out, and a backup machine. Every line is yours to read.

What you'll ship

Real projects, not toy demos.

  • A TCP server that does nothing but echo bytes
  • A complete RESP parser and encoder that any Redis client can talk to
  • A working GET/SET/DEL/EXISTS in-memory store with command dispatch
  • EXPIRE, TTL, and PERSIST with lazy deletion via a sidecar dict
  • AOF persistence with crash-safe append-only writes and replay on startup
  • Point-in-time RDB snapshots written atomically, with copy-on-write BGSAVE
  • SUBSCRIBE / UNSUBSCRIBE / PUBLISH with subscriber sets and live fan-out
  • A read-only replica that does SYNC against a master and applies streaming writes
  • A single-threaded event loop using selectors that beats threaded throughput
  • A benchmark harness comparing your server against real Redis

What you'll learn

You finish able to:

  • Read and write the Redis wire format (RESP) from raw bytes
  • Build a command dispatch table that scales cleanly to dozens of commands
  • Design lazy expiry and understand why production Redis combines lazy and active
  • Implement crash-safe persistence with append-only logs and atomic snapshot writes
  • Architect pub/sub fan-out and replication as plain log shipping over TCP
  • Replace one-thread-per-client with a single-threaded selectors event loop
  • Measure and explain the throughput gap between Python and C implementations

Curriculum

From a TCP socket to your own Redis.

  1. 01

    Network and protocol

    Open a TCP port, read bytes from a client, and learn the Redis wire format (RESP) from scratch.

  2. 02

    Store and expiry

    In-memory KV with command dispatch. Then EXPIRE, TTL, and lazy deletion via a sidecar dict.

  3. 03

    Durability: AOF and RDB

    Append-only logs for crash safety. Point-in-time snapshots for fast recovery. The two pillars of Redis persistence.

  4. 04

    Messaging and replication

    Pub/Sub fan-out and master/replica log shipping. Same RESP wire format underneath both.

  5. 05

    Scaling: Event loop and benchmark

    Replace one-thread-per-client with selectors-based non-blocking IO. Then measure how close (or far) you get from real Redis.

Who it's for

Is this for you?

Backend engineers

You ship features that use Redis but you would freeze if asked to explain how it works in a system design interview.

Python developers leveling up

You have built CRUD APIs and want a project that teaches sockets, protocols, persistence, and concurrency in one stack.

Curious infra people

You want to read the real Redis source code without getting lost. Building a smaller version first makes the navigation easy.

FAQ

Common questions.

  • Do I need to install real Redis?

    No. The workshop ships its own server. Real Redis is useful as a comparison in the final benchmark step, but optional everywhere else.

  • Why Python and not Rust or Go?

    Python keeps the focus on shape. Sockets, dicts, parsing logic are all in the standard library. Step 10 measures the gap to real Redis and explains exactly what changing the implementation language would buy you.

  • Is this Redis-compatible?

    The wire protocol is real RESP, so redis-cli connects and works for the commands we implement. The command coverage is small (SET, GET, DEL, EXISTS, EXPIRE, TTL, KEYS, SUBSCRIBE, PUBLISH, REPLICAOF, SAVE). Production Redis has dozens more.

  • How does it compare to the build-your-own.org Redis book?

    That book is in C. This course is in Python with a slightly different progression (pub/sub and replication land before the event loop). Both are valid paths. The Python version is faster to read and modify.