This website is a free online book about rebuilding Redis™* in Ruby, from scratch. It is still a work in progress, the first ten chapters are currently available, and you can see the planned table of content on the chapters page.

Start reading the first chapter below, or head to the chapters list

Who is this for?

This online book is aimed at people with some programming experience. I am assuming a reasonable level of familiarity with programming concepts such as conditions, loops, classes as well as some understanding of networking. Readers should already have heard of protocols such as HTTP and TCP and I think it would help to have already worked with those. Anyone who worked with a web application, regardless of the language, should have enough experience to read this book. If you’ve worked with a server backend in Ruby, Python, Javascript, or literally anything else, or did frontend work involving fetch and/or ajax, this should be enough!

Lastly, readers should also be familiar with threads and processes. No expertise is required, and I am far from being an expert on the topic, but if you’ve never heard of these, I would advise to glance at the linked wikipedia pages, and to potentially explore the APIs of your favorite languages. Most languages provide tools to interact with threads and processes. Ruby, which we’ll be using in this book, has a Thread class and a Process class.

I am writing this book aiming for it to be useful to five years ago me, when I had about 2 and 3 years of professional experience. I majored in computer science, so back then I had already a few years of experience with programming. That being said, a degree in CS is definitely not required to read this.

On a spectrum from beginner to expert, I would say that this book lands somewhere in the middle, but leaning towards beginner, slightly to the left, so intermediate-ish.

* Redis is a trademark of Redis Labs Ltd. Any rights therein are reserved to Redis Labs Ltd. Any use by this website is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and this website

Chapter 1 - A basic TCP server

This chapter will cover the creation of a TCP server in ruby, as well as how to interact with it with netcat, a utility bundled with macOS and linux. We will briefly look at concurrency and parallelism and how threads can impact the behavior of our server.

Chapter 2 - Respond to Get and Set

In this chapter, we’ll build on the foundations we established in the previous chapter. We now know how to start a TCP server using the built-in TCPServer class. In this chapter we’ll build a basic client using another built-in class, TCPSocket. We’ll then make the server actually usable by making it respond to two commands, GET and SET.”

Chapter 3 - Multiple Clients

In this chapter we will add support for efficient handling of multiple clients connected simultaneously. We will first isolate the problematic elements of the current implementation and explore different solutions before getting to the final one using the select syscall

Liked what you read? Consider subscribing to stay updated!


And if you feel extra generous, consider donating!

Buy me a coffee Buy me a coffee