TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The “Build Your Own Redis” Book Is Completed

599 pointsby bubblehack3rover 2 years ago

25 comments

rcarmoover 2 years ago
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:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;miniredis">https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;miniredis</a> (which I forked to add and experiment with pub&#x2F;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 &quot;ports&quot; are fully functional, but they all helped me sort out some of the above plus build tools, packaging, dependencies, etc.<p>It&#x27;s &quot;hello world&quot; for core cloud native microservices, if you will (and without having to do REST or JSON stuff).
评论 #34574246 未加载
评论 #34573965 未加载
评论 #34585416 未加载
评论 #34577761 未加载
评论 #34573684 未加载
Timpyover 2 years ago
I saw this &quot;Build Your Own Text Editor&quot;[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&#x27;m a believer in the idea of &quot;Build Your Own...&quot; guides now, I hope this Redis guide is just as good as the kilo text editor. I&#x27;m definitely bookmarking this for a deep dive when the time is right. Any other top notch &quot;Build Your Own&quot; recommendations would be highly appreciated.<p>[0] <a href="https:&#x2F;&#x2F;viewsourcecode.org&#x2F;snaptoken&#x2F;kilo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;viewsourcecode.org&#x2F;snaptoken&#x2F;kilo&#x2F;</a>
评论 #34577203 未加载
评论 #34577851 未加载
Jolterover 2 years ago
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&#x2F;client system.”
评论 #34577029 未加载
评论 #34573448 未加载
评论 #34573492 未加载
sunchertaover 2 years ago
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&#x27;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.
评论 #34573385 未加载
tikkabhunaover 2 years ago
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:&#x2F;&#x2F;tokio.rs&#x2F;tokio&#x2F;tutorial&#x2F;setup" rel="nofollow">https:&#x2F;&#x2F;tokio.rs&#x2F;tokio&#x2F;tutorial&#x2F;setup</a>
评论 #34574848 未加载
zX41ZdbWover 2 years ago
It is nice to see more on &quot;build your own database&quot; 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...
评论 #34577984 未加载
tidwallover 2 years ago
Maybe I&#x27;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.
评论 #34573959 未加载
评论 #34575961 未加载
avinasshover 2 years ago
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:&#x2F;&#x2F;github.com&#x2F;avinassh&#x2F;go-caskdb">https:&#x2F;&#x2F;github.com&#x2F;avinassh&#x2F;go-caskdb</a><p>python - <a href="https:&#x2F;&#x2F;github.com&#x2F;avinassh&#x2F;py-caskdb">https:&#x2F;&#x2F;github.com&#x2F;avinassh&#x2F;py-caskdb</a>
BossingAroundover 2 years ago
Is there a public repo we could send PRs&#x2F;MRs&#x2F;patches to? The prose has room for improvement and since the book is free, I&#x27;d love to send a couple of PRs your way.
akieover 2 years ago
This take on &quot;building blocks of modern computing&quot; is fairly opinionated though.<p>They mention &quot;NGINX, SQLite, PostgreSQL, Kafka, Linux kernel, etc.&quot; - of which I&#x27;d only consider NGINX and the Linux kernel (and Redis) as &quot;building blocks&quot;. 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.
评论 #34591330 未加载
viksitover 2 years ago
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).
评论 #34573772 未加载
评论 #34576640 未加载
评论 #34573976 未加载
评论 #34575042 未加载
评论 #34573588 未加载
pull_my_fingerover 2 years ago
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&#x27;m pretty excited to read it and pdfs are pretty hard to read on my device.
评论 #34578953 未加载
messeover 2 years ago
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.
sandgiantover 2 years ago
In the first code snippet in &quot;Introduction to Sockets&quot;, shouldn&#x27;t it be `close(conn_fd)` in the while loop?<p>That confused me a bit. Otherwise this looks interesting, thanks for sharing.
varispeedover 2 years ago
One of my pet peeves when I was learning programming is that I couldn&#x27;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&#x27;t have any TDD experience and I couldn&#x27;t find anywhere how to learn this.<p>Before I even learned that something like testing exist, I was so confident like &quot;oh I could write something like that over the weekend, how come they needed months to do that?&quot;. 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&#x27;t teach someone trying to learn programming much and it doesn&#x27;t actually stand over about million other books about programming that really just scratch the surface and don&#x27;t show how to write production ready code.<p>That&#x27;s what is still missing on the market. It&#x27;s almost like a well kept secret that only developers working at large corporations know.<p>That skill was very very difficult to acquire.
评论 #34573601 未加载
评论 #34574997 未加载
评论 #34578395 未加载
评论 #34574295 未加载
评论 #34573830 未加载
victor106over 2 years ago
&gt; Redis could be considered one of the building blocks of modern computing<p>Is Redis really that critical to modern computing?
评论 #34576083 未加载
评论 #34578406 未加载
feichuanover 2 years ago
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:&#x2F;&#x2F;github.com&#x2F;huangjiahua&#x2F;reredis">https:&#x2F;&#x2F;github.com&#x2F;huangjiahua&#x2F;reredis</a>
danjcover 2 years ago
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.
Dowwieover 2 years ago
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.
评论 #34602944 未加载
评论 #34578798 未加载
cassepipeover 2 years ago
The book seems really interesting but I am quite poor so thanks for making a free web version available. I&#x27;ll think of buying the epub when I earn a wage &lt;3
blacklionover 2 years ago
Am I paranoid, or `container_of` macro is UB in modern C&#x2F;C++, as it cast null pointer to some struct type and operates on members of this type?
yazzkuover 2 years ago
A good read for sure, thank you. &#x27;4. Protocol Parsing&#x27;, hand-writing protocol parsers in C looks particularly thrilling.
评论 #34573347 未加载
评论 #34573288 未加载
eBombzorover 2 years ago
&gt; Here are some examples that meet my criteria of the “building block”: NGINX, SQLite, PostgreSQL, Kafka, Linux kernel, etc.<p>Kafka?
评论 #34573299 未加载
评论 #34572923 未加载
评论 #34573021 未加载
评论 #34574168 未加载
评论 #34573822 未加载
rickreynoldssfover 2 years ago
That&#x27;s something I wish I had time for.
bkuehlover 2 years ago
Redis is great, but sometimes it isn&#x27;t always the best solution.<p>We almost configured it, but instead implemented our own Cache web service and used the built in memory&#x2F;cache management of that. Yes, it&#x27;s only accessible via http but it&#x27;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.