PHPackages                             jspeedz/php-consistent-hashing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jspeedz/php-consistent-hashing

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jspeedz/php-consistent-hashing
==============================

Multi-probe consistent hashing implementation for PHP

1.1.0(1y ago)014.6k↓27.3%1GPL-3.0-onlyPHPPHP &gt;=8.4CI passing

Since Jul 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jspeedz/php-consistent-hashing)[ Packagist](https://packagist.org/packages/jspeedz/php-consistent-hashing)[ RSS](/packages/jspeedz-php-consistent-hashing/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (2)Versions (12)Used By (0)

php-consistent-hashing
======================

[](#php-consistent-hashing)

Multi-probe consistent hashing, using php

The idea behind this package is that you can distribute keys to nodes in a consistent/sticky way, while also allowing for custom weights for each node. This allows you to route 'traffic' to nodes using equal or unequal distributions.

The algorithm should distribute more evenly than for example libketama, which can have a deviation between distributions of equal weight as big as about 10%. For more information on this algorithm and consistent hashing in general, see:

-
- [https://en.wikipedia.org/wiki/Consistent\_hashing](https://en.wikipedia.org/wiki/Consistent_hashing)

Use cases:

- Load balancing distributed caches.
- Data partitioning.
- Selecting a specific server and sticking with it (consistent routing).
- Distributing users over several groups. For use in A/B testing for example.

Example usage:

```
$hasher = new \Jspeedz\PhpConsistentHashing\MultiProbeConsistentHash();
// Choose which hash functions to use
$hasher->setHashFunctions((new \Jspeedz\PhpConsistentHashing\HashFunctions\Standard)());
```

Usage with equal weights:

```
$hasher->addNode('node1');
$hasher->addNode('node2');
$hasher->addNode('node2');

$node = $hasher->hash('some_key1');
```

Usage with custom weights (I like to use percentages):

```
$hasher->addNode('node1', 25);
$hasher->addNode('node2', 33.3);
$hasher->addNode('node2', 41.7);

$node = $hasher->hash('some_key1');
```

Note: if you add a node without specifying a weight, the weight will be set to 1.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance43

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~78 days

Total

9

Last Release

458d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.2

1.1.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb11ec1babdb8301abc53495e9bc4f1c59d5c29780ef022f15089492b1408b21?d=identicon)[jspeedz](/maintainers/jspeedz)

---

Top Contributors

[![jspeedz](https://avatars.githubusercontent.com/u/6095226?v=4)](https://github.com/jspeedz "jspeedz (49 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jspeedz-php-consistent-hashing/health.svg)

```
[![Health](https://phpackages.com/badges/jspeedz-php-consistent-hashing/health.svg)](https://phpackages.com/packages/jspeedz-php-consistent-hashing)
```

###  Alternatives

[foxbytehq/laravel-backed-enums

Supercharge your PHP8 backed enums with superpowers like localization support and fluent comparison methods.

451.6k](/packages/foxbytehq-laravel-backed-enums)[markguinn/silverstripe-gridfieldmultiselect

Gridfield extensions to add checkboxes for each row to easily delete or perform actions on multiple rows.

106.0k](/packages/markguinn-silverstripe-gridfieldmultiselect)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
