I actually build minimal Redis clones in every new language or runtime, or when I want to explore threading models.<p>It all started with <a href="https://github.com/rcarmo/miniredis">https://github.com/rcarmo/miniredis</a> (which I forked to add and experiment with pub/sub), and I just found myself doing it again and again because Redis is the quintessential network service:<p>By implementing it, you learn about socket handling, event loop for a specific runtime, threading models, data representation, concurrency (if you want to do a multi-threaded version), etc. None of my "ports" are fully functional, but they all helped me sort out some of the above plus build tools, packaging, dependencies, etc.<p>It's "hello world" for core cloud native microservices, if you will (and without having to do REST or JSON stuff).
I saw this "Build Your Own Text Editor"[0] on HN a month or two ago, everyone was raving about it so I went through it and it really was fantastic. The learning experience was unparalleled. I'm a believer in the idea of "Build Your Own..." guides now, I hope this Redis guide is just as good as the kilo text editor. I'm definitely bookmarking this for a deep dive when the time is right. Any other top notch "Build Your Own" recommendations would be highly appreciated.<p>[0] <a href="https://viewsourcecode.org/snaptoken/kilo/" rel="nofollow">https://viewsourcecode.org/snaptoken/kilo/</a>
While I applaud the initiative and effort, I want to urge the author to consult a good proofreader. I’m only in chapter 2 yet I’ve already encountered enough friction in the form of poor English to put me off. I think the substance looks great, so it’s a bit wasteful to not walk the last mile and make it genuinely enjoyable to read by eliminating blatant errors like this one:<p>“The Redis is an example of the server/client system.”
I am very happy to see more content like this (attempting to teach how to create a real system) becoming available.
Few month ago there was a launch announcement of YC backed startup that sell you walk-through labs guiding you to build Redis, Docker, Git and others. (Can't find link to it now.)<p>What is still missing, in my opinion, and is badly needed, is content or even an idea on how to teach taking such projects from toy prototype version to the production quality one.
Sorry for being a little off topic, but the Mini Redis tutorial [1] was really fun when I did it a few years ago. It has you implement a server and client in Rust using the Tokio library.<p>I think Redis is a great server to “build yourself” as you don’t need to start with much to get it going.<p>[1] <a href="https://tokio.rs/tokio/tutorial/setup" rel="nofollow">https://tokio.rs/tokio/tutorial/setup</a>
It is nice to see more on "build your own database" topics.<p>Although people constantly bug me on attempts to build their own ClickHouse. Someone is trying to do it with Apache Arrow and DataFusion. Folks from DuckDB are trying to build their own crippled version of ClickHouse. Friends from China doing it with their Apache Doris. InfluxDB is being rewritten to be closer to ClickHouse in an attempt to make it better and so on...
Maybe I'm missing something but the server application resulting from the source code in this book does not actually work with redis-cli or any Redis clients. It appears to be using a custom binary protocol, not valid RESP.
I feel that the RESP protocol itself is the most challenging task of building ones own Redis.
I am a big fan of Build Your Own X educational projects. Recently, I released a Go version of my build your own KV Store project. I have set up this project in TDD fashion with the tests. So, you start with simple functions, pass the tests, and the difficulty level goes up. There are hints if you get stuck (e.g. link). When all the tests pass, you will have written a persistent key-value store.<p>go - <a href="https://github.com/avinassh/go-caskdb">https://github.com/avinassh/go-caskdb</a><p>python - <a href="https://github.com/avinassh/py-caskdb">https://github.com/avinassh/py-caskdb</a>
Is there a public repo we could send PRs/MRs/patches to? The prose has room for improvement and since the book is free, I'd love to send a couple of PRs your way.
This take on "building blocks of modern computing" is fairly opinionated though.<p>They mention "NGINX, SQLite, PostgreSQL, Kafka, Linux kernel, etc." - of which I'd only consider NGINX and the Linux kernel (and Redis) as "building blocks". The others might be part of their own preferred stack, but if you mention Postgres, why not MySQL? If Kafka, why not RabbitMQ?<p>But yeah, NGINX, Redis, and the Linux kernel are basically outside of discussion.
i love this! is there a book like this to learn rust with? it would be amazing to have a working system at the end. (not looking for a beginner, but say, intermediate level book).
Purchased this via Gumroad, but the epub version seems to not be formatted correctly. After about page 3 it decides the book is finished on my Kobo. Hopefully the author will get a fix out, I'm pretty excited to read it and pdfs are pretty hard to read on my device.
Looks neat and relatively self contained. I’m adding this to my list of projects to use to learn a new language. I might give it a shot in Kotlin and Zig (I know it and use it, but am not as familiar with its event loop implementation as I’d like to be) over the next few weeks.
In the first code snippet in "Introduction to Sockets", shouldn't it be `close(conn_fd)` in the while loop?<p>That confused me a bit. Otherwise this looks interesting, thanks for sharing.
One of my pet peeves when I was learning programming is that I couldn't find any books that would teach how to write tests in real world.<p>There was that chicken and egg problem then, when potential employers would skip my CV because I didn't have any TDD experience and I couldn't find anywhere how to learn this.<p>Before I even learned that something like testing exist, I was so confident like "oh I could write something like that over the weekend, how come they needed months to do that?". Then my software would crash the first time someone other than me used it.<p>Anyway - what I want to say that while this book sounds like a great idea, without showing TDD and how to write code so that it can be proven it works the way intended and that it can handle unhappy paths and edge cases, it won't teach someone trying to learn programming much and it doesn't actually stand over about million other books about programming that really just scratch the surface and don't show how to write production ready code.<p>That's what is still missing on the market. It's almost like a well kept secret that only developers working at large corporations know.<p>That skill was very very difficult to acquire.
I did something similar by building Redis in Rust a few years ago. It’s a really good learning and exercise to a lot of topics like network programming. <a href="https://github.com/huangjiahua/reredis">https://github.com/huangjiahua/reredis</a>
Kudos to the author for a very succinct, practical book. It would be nice to see a few chapters on high availability though - seems to me that failover and consistency guarantees are one of the really hard bits.
Is anyone aware of an in-depth explanation about how key-value store persistence, such as Redis RDB, is built? A guide on compaction would be really interesting and useful.
The book seems really interesting but I am quite poor so thanks for making a free web version available.
I'll think of buying the epub when I earn a wage <3
Redis is great, but sometimes it isn't always the best solution.<p>We almost configured it, but instead implemented our own Cache web service and used the built in memory/cache management of that. Yes, it's only accessible via http but it's given us a lot of flexibility. We are primarily using it for caching of large datasets (hundreds of MBs). When service has to be restarted, it makes a call to get all the items it needs.