‹ BackHN Continuity

Thread

Saving another 100TB of RAM

488 points · 123 comments · f311a

  1. officialchicken · · focus · HN ↗

    [dead]

    1. cyberpunk · · focus · HN ↗
      Anyone have an idea how it behaves differently from google's jump hash algorithm? The cool thing about google's one is it's so short I can include it in a HN comment:

          int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
            int64_t b = 1, j = 0;
            while (j < num_buckets) {
              b = j;
              key = key * 2862933555777941757ULL + 1;
              j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1));
            }
            return b;
          }
      
      <a href="https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1406.2294" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1406.2294
      1. cyberpunk · · focus · HN ↗
        Well I looked it up; nginx, apparently, uses ketama -- it&#x27;s a ring-style hash probably works better for web backends than the jch above, as when given [0,1,2,3] and replacing the server in slot 1 you&#x27;re going to have a lot of hash moves. With ketama, you&#x27;d only have the &#x27;1&#x27; hashes moving. You can&#x27;t really beat google&#x27;s for brevity, though.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.