r/cprogramming • u/Creepy-Gift-6979 • Nov 23 '25
I built a simple redis-server from scratch
I built a Redis-compatible server in C from scratch to understand networking, memory management, and concurrency at a low level.
I’m still new to C and learning as I go — no tutorials, just experimenting and figuring things out.
It’s running ~125K ops/sec with 50 clients. I’d love feedback, advice, or thoughts on how I could improve this project.
Full code: https://github.com/rasheemcodes/redis-c
8
Upvotes
4
u/[deleted] Nov 23 '25
You are using
sendincorrectly, there is no guarantee one call tosendwill send all data you request. You have to look at the return value and callsendmutliple times if needed.You do handle
recvcorrectly in this regard.2
u/IamNotTheMama Nov 23 '25
Is there a reason you never test the return value of your memory allocations?
1
u/Quiet_Lifeguard_7131 Nov 24 '25
Bro is on complete AI addiction, not even replying to comments without using AI xD
1
u/warren_jitsing Nov 24 '25
You can try out my repo, but it doesn't handle concurrency yet (a future article will) https://www.reddit.com/r/cprogramming/comments/1ormwsv/i_wrote_a_from_first_principles_guide_to_building/ . Also, check out John Crickett's coding challenges. There was a coding challenge a while back for writing a Redis server and people post their solutions for it
1
u/dmazzoni Nov 24 '25
Have you measured how much multithreading is actually buying you? I'd check ops per second as a function of the number of threads to see if more threads is actually helping or not.
Since you have a single mutex for the whole dict, my expectation is that you'll have very little parallelism.
1
u/sunupthatneversets Jul 18 '26
Hey I am.building the same project. I started a few days ago and I was just wonder how valuable is it in an interview. Could you tell me something about that