The “Build Your Own Redis” Book is Completed

James Smith


Read it here.


Needless to say, the Redis project is quite a success. It’s an important component in backend applications.

Redis could be considered one of the building blocks of modern computing. There are not many projects that fit the such role and stood the test of time. Here are some examples that meet my criteria of the “building block”: NGINX, SQLite, PostgreSQL, Kafka, Linux kernel, etc.

Most of us are not working on projects of such a level, but it is still worthwhile to learn from those projects. It takes higher skill and deeper knowledge to build such projects, thus learning from those projects could be a path to the next level as a software developer. The book is the result of my own learning.

Why a Book?

My motivations for writing this book:

Why From Scratch?

A couple of points:

Summarized in a quote from Feynman: “What I cannot create, I do not understand”.

Why Redis?

What makes Redis a good target is that it covers two important subjects of software engineering: network programming and data structures.

While there are many guides and books on network programming, I find that there are still some gaps to be filled:

Data structures are interesting topics, and what’s interesting in Redis is that Redis only employs a few basic data structures, yet it is quite versatile and covers quite a lot of real-world use cases.

Although many people learned some basic data structures from textbooks, there is still something more to learn. Data structures implemented in real projects often have some practical considerations which are not touched by textbooks. Learning how data structures are used in a non-toy environment is a unique experience from building Redis.

The Book

I have split the contents into short chapters, each chapter builds on the previous one, adding a new concept. The full source code is provided for reference purposes, readers are advised to tinker with it or DIY without it.

The code is written as direct and straightforwardly as I could. It’s mostly plain C with minimal C++ features. Don’t worry if you don’t know C, you just have the opportunity to do it in another language by yourself.

The end result is a mini Redis alike with only about 1200 lines of code. 1200 LoC seems low, but it illustrates many important aspects the book attempts to cover.

The techniques and approaches used in the book are not exactly the same as the real Redis. Some are intentionally simplified, and some are chosen to illustrate a general topic. Readers can learn even more by comparing different approaches.

The book is relatively short — the paperback is 120 pages of pure content in a compact size (6x9in), and no fluffs are included.

Read the free web version here. If it’s helpful to you, consider purchasing the ebook or a hard copy.

Welcome to build-your-own.org.

A website for free educational software development materials.


for updates and new books.

Build Your Own X From Scratch Book Series:

Build Your Own Redis
Build Your Own Database
Build Your Own Compiler
Build Your Own Webserver