<< All versions
Skill v1.0.0
currentAutomated scan100/100alizainx/intelligence-systems-skills/consistent-hashing-sharding-rebalance
──Details
PublishedNovember 5, 2026 at 12:32 PM
Content Hashsha256:7c47b0d0e5b4c2a8...
Git SHA5d098c90c1e6
──Files
Files (1 file, 2.2 KB)
SKILL.md2.2 KBactive
SKILL.md · 27 lines · 2.2 KB
name: consistent-hashing-sharding-rebalance id: ISS-168 token_budget: 700 chain_with: [raft-paxos-consensus-replication, crdt-hlc-causal-consistency, grpc-http3-backpressure-load-shedding] description: "Partitioned distributed storage: Consistent Hashing with Bounded Loads, Rendezvous (HRW) hashing, virtual nodes, hot-key splitting, and zero-downtime migration." metadata: version: "1.0.0"
consistent-hashing-sharding-rebalance (ISS-168)
1. First-Principles Invariant
- Karger/Mirrokni Bounded-Load Consistent-Hashing Law: Map each physical node to $V \ge 150$ virtual tokens on the $[0, 2^{64}-1]$ ring (or use Highest Random Weight Rendezvous hashing $\arg\max_{n} \text{hash}(key, n)$) and cap each node's load at $\lceil c \cdot (K / N) \rceil$ ($c = 1.25$), forwarding overflow keys to the next clockwise node with spare capacity so adding/removing a node moves only $O(K/N)$ keys while bounding peak imbalance.
2. Fast-Pass Low-Token Protocol (Web & Coding Agents)
- Detect power-law hot keys (
Zipfskew) via a heavy-hitter Count-Min Sketch / Top-K tracker and append a bounded random saltkey#0..S-1for read replication or split the hot range dynamically.
3. Zero-Bug & Zero-Vulnerability Guards
- Use a fast, deterministic, seed-stable 64-bit hash (
xxHash64,SipHash-2-4,MurmurHash3_x64_128) — never language-runtime randomized hashes (Python hash(),Go maphashacross restarts) for persistent shard routing. - Co-locate related tenant/entity rows on the same shard using a composite partition key
(tenant_id, entity_id)whereshard = hash(tenant_id)so single-tenant joins and transactions never cross shards. - Execute online shard splits and migrations via a 4-phase state machine:
SourceOnly -> DualWrite/BackfillCatchup -> ReadCutover -> SourceCleanup, gated by epoch numbers (ConfigEpoch) rejected by stale nodes. - Place the $R=3$ replicas of each shard across distinct failure domains (
rack,availability_zone,power_pdu) on the ring. - Verify key movement ratio ($\approx 1/N$) and max-to-mean load ratio ($\le 1.25$) across simulated node additions and removals.
4. Verification Gate
python3 -c 'import hashlib, bisect; ...'