Capstone: Measure your server against real Redis
You built it. Now measure it. The numbers themselves do not tell the lesson. The gap between your server and real Redis does, because the architecture is the same. The implementation language is the lever.
def run_phase(host, port, n, concurrency, op):
per_thread = n // concurrency
threads, latencies = [], []
lock = threading.Lock()
t0 = time.perf_counter()
for _ in range(concurrency):
t = threading.Thread(target=worker, args=(host, port, per_thread, op, latencies, lock))
t.start(); threads.append(t)
for t in threads: t.join()
elapsed = time.perf_counter() - t0
latencies.sort()
return {
"total_ops": len(latencies),
"elapsed_s": elapsed,
"throughput": len(latencies) / elapsed,
"p50_ms": statistics.median(latencies),
"p99_ms": latencies[int(len(latencies) * 0.99) - 1],
}The benchmark sends N operations across C concurrent connections, records per-op latency, prints throughput + p50/p99.
Where the gap comes from
The lesson: the architecture is sound. A 5-10x gap to real Redis is closeable by porting hot paths to Rust or by adding pipelining and vectored IO. Architecture is the moat. Implementation is engineering.
Validation checklist: Pick a follow-up project and ship it
Loading practice…
Checkpoint: Final checkpoint: Do you own the architecture?
Loading practice…