<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akshat Paul 👨‍💻</title>
    <description>The latest articles on DEV Community by Akshat Paul 👨‍💻 (@akshatpaul).</description>
    <link>https://dev.to/akshatpaul</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F126734%2F9df8a3c6-e488-4bc8-99c8-8e13c8637cc5.jpg</url>
      <title>DEV Community: Akshat Paul 👨‍💻</title>
      <link>https://dev.to/akshatpaul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshatpaul"/>
    <language>en</language>
    <item>
      <title>Consistent Hashing: The System Design Interview Concept Everyone Gets Wrong</title>
      <dc:creator>Akshat Paul 👨‍💻</dc:creator>
      <pubDate>Thu, 20 Aug 2026 17:25:30 +0000</pubDate>
      <link>https://dev.to/akshatpaul/consistent-hashing-the-system-design-interview-concept-everyone-gets-wrong-41i0</link>
      <guid>https://dev.to/akshatpaul/consistent-hashing-the-system-design-interview-concept-everyone-gets-wrong-41i0</guid>
      <description>&lt;p&gt;Most candidates say "use consistent hashing" in a system design interview and stop there.&lt;/p&gt;

&lt;p&gt;That's not enough anymore.&lt;/p&gt;

&lt;p&gt;I made a video breaking this down from first principles — the hash ring, virtual nodes, and a nuance most tutorials skip entirely: virtual nodes fix data balance, not traffic balance. Here's the short version, if you want the TL;DR before watching.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/ESjwe-1Ls9M"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The problem with naive hashing&lt;/p&gt;

&lt;p&gt;The obvious way to distribute keys across servers is hash(key) % N. Simple — until N changes.&lt;/p&gt;

&lt;p&gt;Add or remove one server, and the modulo result flips for almost every key. In practice, adding a single server to a naively-hashed cluster can remap ~75% of your keys. That's a cache stampede waiting to happen: every remapped key is a cache miss, and your database eats the traffic your cache was supposed to absorb.&lt;/p&gt;

&lt;p&gt;The fix: a hash ring&lt;/p&gt;

&lt;p&gt;Instead of a line, imagine the hash space as a circle — 0 to 2³²−1, wrapping back to 0.&lt;/p&gt;

&lt;p&gt;Both servers and keys get hashed onto this same ring. A key belongs to the first server it hits walking clockwise. That one change means:&lt;/p&gt;

&lt;p&gt;Adding a server only remaps the small arc of keys between it and its predecessor — not the whole ring.&lt;br&gt;
Removing a server only shifts its keys to the next server clockwise — everything else is untouched.&lt;/p&gt;

&lt;p&gt;Roughly K/N keys move per change, not the whole dataset.&lt;/p&gt;

&lt;p&gt;The catch: uneven load&lt;/p&gt;

&lt;p&gt;With only a handful of servers, their positions on the ring are essentially random — which means they can cluster unevenly. One server can end up owning a huge arc while others sit nearly idle.&lt;/p&gt;

&lt;p&gt;Fix: virtual nodes. Hash each physical server onto the ring 100-200 times (ServerA-1, ServerA-2, ...) instead of once. More points → the arcs even out via the law of large numbers → under 5% load variance between machines in practice.&lt;/p&gt;

&lt;p&gt;Most candidates stop here. That's a mistake.&lt;/p&gt;

&lt;p&gt;The part most people miss: hot keys&lt;/p&gt;

&lt;p&gt;Virtual nodes fix structural imbalance — every server holds roughly the same number of keys. They do nothing for traffic imbalance.&lt;/p&gt;

&lt;p&gt;If one specific key goes viral — a celebrity profile, a trending product — every read for that key still routes to the same server, no matter how many virtual nodes you have. Two common mitigations:&lt;/p&gt;

&lt;p&gt;Read replicas — replicate the hot key, load-balance reads across copies.&lt;br&gt;
Key salting — append a random suffix (key-0 through key-9) to spread it across multiple ring positions, then aggregate on read.&lt;/p&gt;

&lt;p&gt;If you can articulate the difference between data balance and traffic balance in an interview, you're already ahead of most candidates.&lt;/p&gt;

&lt;p&gt;Where this actually runs&lt;/p&gt;

&lt;p&gt;Not theoretical — this is running in production systems you already use:&lt;/p&gt;

&lt;p&gt;DynamoDB — partition key routing&lt;br&gt;
Cassandra — token-ring based partitioning&lt;br&gt;
Redis Cluster — hash slots&lt;br&gt;
CDNs (Akamai) — routing to the nearest edge node&lt;br&gt;
Riak — distributed KV partitioning&lt;br&gt;
Load balancers — sticky sessions without a central session map&lt;br&gt;
Full video&lt;/p&gt;

&lt;p&gt;The video covers all of this with visual, ring-based diagrams for each step (adding/removing nodes, virtual nodes, hot keys) — worth a watch if you want the full walkthrough rather than the text summary.&lt;/p&gt;

&lt;p&gt;📺 &lt;a href="https://youtu.be/ESjwe-1Ls9M" rel="noopener noreferrer"&gt;Watch here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Curious what other system design topics people want broken down like this — drop a comment below.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>distributedsystems</category>
      <category>interview</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
