Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack safer

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
012345678901234567890123456789012345678901234567890123456789
Yesterday
012345678901234567890123456789012345678901234567890123456789
Total views
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Developer docs
Consistent hashing
Consistent hashingReference implementationStep-by-step guideOfficial docs and resourcesDiscussionsComments

Other algorithms

Algorithm basics5
Complexity analysisSortingSearchingBasic data structuresTrees and heaps
Core algorithms6
Graph traversalShortest paths & minimum spanning treesDynamic programmingGreedy algorithmsDivide and conquerBacktracking
Advanced algorithms5
String algorithmsMath and number theoryBit manipulationSegment treesUnion-find
Practical algorithms3
Coding interview strategyLRU cacheRate limiting

Algorithm

Consistent hashing

Consistent hashing spreads keys across servers so that adding or removing a node moves only the keys that must move; used in caches, stores and load balancers.

Start the guideDiscussions

Consistent hashing is a way to distribute keys across many servers, introduced by Karger et al. in 1997 for distributed web caching. It treats the hash space as a ring, places both servers and keys on it, and assigns each key to the first server found clockwise from it. Giving each server many points on the ring, called virtual nodes, evens out the load.

With hash(key) % N, changing the server count relocates almost every key, wiping out cache hit rates and forcing massive data movement. Consistent hashing moves on average only 1/(N+1) of the keys when a server joins, and only onto the new server, so clusters can grow and shrink while running. Ketama in Memcached clients, the Amazon Dynamo paper, Cassandra, and the consistent hash options in Nginx and HAProxy all build on this idea.

Start by computing how many keys mod-N sharding moves, then implement a hash ring with a sorted array and binary search. Next, measure how the load spread shrinks as you add virtual nodes, and compare replica selection, rendezvous hashing and jump consistent hash. That foundation also lets you explain the trade-offs clearly in system design interviews.

On this page

  1. Highlights
  2. Where it is used
  3. Reference implementation
  4. Step-by-step guide
  5. Official docs and resources
  6. Discussions
  7. Comments

Highlights

Minimal movement

Adding or removing a node moves about 1/(N+1) of the keys in expectation, and existing nodes never trade keys with each other.

Hash ring

The hash space is a circle and a key belongs to the first node clockwise from it. A lookup is a binary search over sorted positions.

Virtual nodes

Many points per node reduce load imbalance, and the number of points expresses differences in server capacity.

Replication and alternatives

Replicas go to the next R distinct nodes clockwise; rendezvous hashing and jump hash reach the same goal by other means.

Where it is used

  • Client-side sharding for distributed caches such as Memcached
  • Partitioning and replication in Dynamo-style stores such as Cassandra
  • Request affinity in Nginx, HAProxy and Envoy load balancing
  • Distributed hash tables such as Chord

Reference implementation

A hash ring with virtual nodes

The first 8 bytes of an MD5 digest serve as the ring position, and each node gets 100 virtual nodes inserted into a sorted list with bisect.insort. get uses bisect_left to find the first point at or after the key and wraps around past the end. Adding node D moves only about a quarter of the keys, and removing it again sends every key back to its original node.

consistent_hashing.py

import bisect
import hashlib


def h(key: str) -> int:
    return int.from_bytes(hashlib.md5(key.encode()).digest()[:8], "big")


class HashRing:
    def __init__(self, nodes=(), vnodes=100):
        self.vnodes = vnodes
        self.points = []   # sorted hash positions on the ring
        self.owner = {}    # position -> physical node
        for node in nodes:
            self.add(node)

    def add(self, node):
        for i in range(self.vnodes):
            p = h(f"{node}#{i}")
            bisect.insort(self.points, p)
            self.owner[p] = node

    def remove(self, node):
        for i in range(self.vnodes):
            p = h(f"{node}#{i}")
            self.points.pop(bisect.bisect_left(self.points, p))
            del self.owner[p]

    def get(self, key):
        if not self.points:
            raise LookupError("ring is empty")
        i = bisect.bisect_left(self.points, h(key)) % len(self.points)
        return self.owner[self.points[i]]


ring = HashRing(["A", "B", "C"])
keys = [f"user:{n}" for n in range(10_000)]
before = {k: ring.get(k) for k in keys}
ring.add("D")
moved = sum(before[k] != ring.get(k) for k in keys)
print(f"moved {moved / len(keys):.1%} of keys")  # about 25%
ring.remove("D")
print(all(ring.get(k) == before[k] for k in keys))  # True
python consistent_hashing.py

Step-by-step guide

Six chapters that take you from installation to the core ideas of Consistent hashing.

  1. Consistent hashing concepts
  2. How it works
  3. Implementation
  4. Complexity
  5. Practice problems
  6. Real-world use

Official docs and resources

  • Officialbisect — Array bisection algorithm
  • OfficialNginx upstream module: hash
  • OfficialApache Cassandra: Dynamo architecture
  • ReferenceConsistent hashing (Wikipedia)
  • ReferenceRendezvous hashing (Wikipedia)
  • ReferenceA Fast, Minimal Memory, Consistent Hash Algorithm (Lamping & Veach)
  • ReferenceDynamo: Amazon's Highly Available Key-value Store
  • ReferenceChord (peer-to-peer) (Wikipedia)

Discussions

Start a discussion

Ask questions, share experience and trade opinions about Consistent hashing.

No discussions yet. Start the first one.

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.