Skip to content

jcar787/consistent-hashing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Week 2 - Consistent Hashing (Go + React)

Motivation: Implement ByteByteGo system design problems to deepen system-design intuition while building production-quality Go services.

Goal: Build a consistent-hashing service that maps keys to nodes with minimal remapping on membership changes, expose a simple HTTP API, and visualize the ring and key distribution via a TypeScript/React UI.


System Design Concepts

  • Consistent Hashing – Place both nodes and keys on the same hash ring (0..2³²−1). A key is owned by the first node clockwise from its hash.
  • Virtual Nodes (VNodes) – Represent each physical node multiple times on the ring to smooth out uneven distribution (default: V=100).
  • Replication Factor (R) – Return R distinct owners per key to improve availability (e.g., primary + fallbacks).
  • Minimal Movement – Adding one node to N nodes moves ~1/(N+1) of keys (vs. ~all keys with naive modulo hashing).
  • Weighted Nodes (later) – Assign more vnodes to larger machines to bias load proportionally.
  • Failure & Churn (later) – Detect dead nodes, remove from ring, and reassign their ranges automatically.

Architecture

flowchart LR
    UI[React UI] --> | GET /lookup?key=... | API(Go HTTP API)
    UI --> | POST /nodes | API
    UI --> | DELETE /nodes/:id | API
    UI --> | GET/POST /replication | API
    API --> | in-mem calls | Ring[(HashRing: VNodes + R)]
    API --> | JSON | UI
    classDef dim fill:#eee,stroke:#bbb,color:#777;
Loading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published