fivenines
All tracks

Guided learning track

Build Your Own Redis

Redis-inspired in-memory data store built from key-value command execution through protocol handling, storage internals, persistence, replication, failover, and cluster sharding.

Next up

Single-node Core · Tutorial 1 of 24

Single-Node Key-Value Core

20 min · 0% complete
Start tutorial
Full curriculum10 modules · 24 tutorials
01

Single-node Core

0/1 done

Build command-owned in-memory key-value behavior before adding protocol or scheduling concerns.

01
Tutorial 120 min

Single-Node Key-Value Core

Build GET, SET, and DEL around one in-memory dictionary while defining clear command, reply, and missing-key semantics.

ArticlePracticeDesign
Not startedStart
02

Network Protocol

0/2 done

Add byte framing and client connection lifecycle after command semantics are stable.

02
Tutorial 220 min

RESP Protocol Parser

Parse incremental RESP frames safely across partial reads, nested values, and malformed input before dispatching commands.

ArticlePracticeDesign
Not startedStart
03
Tutorial 325 min

Client Connection Lifecycle

Trace each client from accept through buffered reads, command execution, queued replies, and connection teardown.

ArticlePracticeDesign
Not startedStart
03

Execution Core

0/2 done

Introduce the single-threaded reactor and metadata-driven command dispatch.

04
Tutorial 425 min

Event Loop

Multiplex file readiness and timer work in one event loop while keeping handlers short enough to preserve responsiveness.

ArticlePracticeDesign
Not startedStart
05
Tutorial 525 min

Command Table And Dispatch

Drive validation, authorization, and execution from command metadata instead of hard-coding a separate request path for every command.

ArticlePracticeDesign
Not startedStart
04

Data Model

0/3 done

Explain object representation, dictionary maintenance, and typed payloads one mechanism at a time.

06
Tutorial 620 min

Redis Object Model

Separate logical value types from physical encodings so representation can change without changing command semantics.

ArticlePracticeDesign
Not startedStart
07
Tutorial 725 min

Hash Table And Rehashing

Spread hash-table resizing across ordinary operations so rehashing avoids a single latency spike while lookups consult both tables.

ArticlePracticeDesign
Not startedStart
08
Tutorial 825 min

Core Data Types

Choose encodings and operations for lists, hashes, sets, and sorted sets according to their access patterns and size.

ArticlePracticeDesign
Not startedStart
05

Memory Lifecycle

0/2 done

Separate time-based expiration from memory-pressure eviction.

09
Tutorial 925 min

Expiration System

Combine lazy expiration on access with sampled active cleanup so expired keys disappear without blocking the server.

ArticlePracticeDesign
Not startedStart
10
Tutorial 1025 min

Memory Limits And Eviction

Enforce maxmemory by selecting victims under an explicit eviction policy whose trade-offs match the workload.

ArticlePracticeDesign
Not startedStart
06

Command Behavior

0/5 done

Add queued, atomic, fanout, and log-like command behaviors after core data types exist.

11
Tutorial 1125 min

Pipelining And Output Buffers

Pipeline requests to reduce round trips while bounding per-client output buffers so slow consumers cannot exhaust memory.

ArticlePracticeDesign
Not startedStart
12
Tutorial 1230 min

Transactions

Queue commands between MULTI and EXEC, and use WATCH to abort optimistic transactions when observed keys change.

ArticlePracticeDesign
Not startedStart
13
Tutorial 1325 min

Scripts/functions

Execute server-side scripts atomically by blocking interleaving, while controlling runtime so one script cannot stall every client.

ArticlePracticeDesign
Not startedStart
14
Tutorial 1425 min

Pub/Sub

Fan published messages out to channel and pattern subscribers while accepting Pub/Sub's transient, at-most-once delivery semantics.

ArticlePracticeDesign
Not startedStart
15
Tutorial 1530 min

Streams

Use ordered stream IDs, pending-entry tracking, acknowledgements, and claiming to divide durable work among consumers.

ArticlePracticeDesign
Not startedStart
07

Persistence

0/3 done

Persist and rebuild the in-memory database with snapshots and append-only history.

16
Tutorial 1630 min

RDB Snapshotting

Create point-in-time snapshots with fork and copy-on-write, balancing compact recovery files against snapshot cost and possible data loss.

ArticlePracticeDesign
Not startedStart
17
Tutorial 1730 min

AOF Persistence

Use an append-only command log plus background rewrite to trade recovery fidelity against write amplification and file growth.

ArticlePracticeDesign
Not startedStart
18
Tutorial 1830 min

Startup Recovery

Restore persisted state by loading an RDB snapshot or replaying AOF commands before accepting client traffic.

ArticlePracticeDesign
Not startedStart
08

Replication And Failover

0/3 done

Copy state to replicas, resume streams, and promote safely after failure.

19
Tutorial 1930 min

Replication: Full Sync

Bootstrap a replica from a consistent snapshot, then stream buffered writes so it catches up without losing changes made during transfer.

ArticlePracticeDesign
Not startedStart
20
Tutorial 2030 min

Replication: Partial Sync

Resume replication from IDs, offsets, and a bounded backlog when history is available, falling back to full synchronization when it is not.

ArticlePracticeDesign
Not startedStart
21
Tutorial 2130 min

Failover Controller

Use independent monitors, quorum, and epochs to promote one replica without letting competing observers create split-brain.

ArticlePracticeDesign
Not startedStart
09

Clustering

0/2 done

Split key ownership across nodes and move ownership online.

22
Tutorial 2230 min

Cluster Sharding

Partition keys into hash slots and use MOVED redirects so clients can discover which node owns each key.

ArticlePracticeDesign
Not startedStart
23
Tutorial 2330 min

Cluster Resharding

Move hash slots live with migrating and importing states, ASK redirects, and dual-node coordination that preserves availability.

ArticlePracticeDesign
Not startedStart
10

Capstone

0/1 done

Compose the learned Redis-like mechanisms without introducing new core concepts.

24
Tutorial 2430 min

track Redis-Like System

Integrate protocol parsing, event handling, data structures, persistence, replication, and clustering into one coherent Redis-like system.

ArticlePracticeDesign
Not startedStart