Build Your Own Redis Challenge
I’ve found ‘Build Your Own X’ tutorials to be a very effective way of improving my understanding of tools we use everyday, like Git, Docker, Redis etc.
What I cannot create, I cannot understand
- Richard Feynman
The problem with many of these tutorials is that they aren’t interactive. It’s okay when tutorials are small, but as they grow in size it can get very hard to follow.
I wish there was a HackerRank-like product where I could, over time, complete ~20 steps and build a large-ish program, while receiving constant TDD-style feedback. This could also be used as a recruiting tool.
This ‘Build Your Own Redis’ challenge is an attempt at such a product. It serves as a code-along challenge for my ‘Build Your Own Redis’ series.
How it works
You start out by choosing the language you want to attempt the challenge in.
Note: I’ve got support for Python, Go and Swift at the moment. More languages will be added soon.
You’ll then be asked to clone a Git repository, and push an empty commit to start the challenge.
When you run
git push, you’ll see test results streamed to your terminal.
At each stage, you’re expected to commit code that passes certain tests. As you progress, the stages get harder and harder:
Redis Challenge Stages
Here are the stages in the Redis challenge:
Stage 0: Bind to a port
Spawn a TCP server that binds to Redis’s default port and accepts connections from clients.
Stage 1: PING <-> PONG
Respond to a
PING command. You’ll need to
reply using the Redis Protocol.
Stage 2: ECHO… O… O…
Respond to an
ECHO command. In stage 1, you
didn’t really have to parse what the user sent you, but in this stage you
will. Time to parse RESP!
Stage 3: Multiple Clients
Handle multiple clients at once.
Resist the temptation to use multiple threads. Do this using a single thread (like the original Redis does!). Hint: Build an event loop using select.
Stage 4: SET & GET
Implement SET and GET. Your server must now be capable of holding state!
Stage 5: Expiry!
There’s a flag in SET that allows a client to set an expiry on a key. Find it, and add it to your Redis implementation.
Note: Contact me if you’d like to suggest next stages.
How do I try this out?
Signup for early access at CodeCrafters.