php一致性hash类下载地址:http://code.google.com/p/flexihash/
<?
require_once 'flexihash.php';
$hostArr = array(
'img1.marx.com',
'img2.marx.com',
'img3.marx.com',
'img4.marx.com',
'img5.marx.com',
'img6.marx.com',
...
);
$hash = new Flexihash();
$hash->addTargets($hostArr);
$src = $_SERVER['REMOTE_ADDR'];
echo $hash->lookup($src);
分布的均匀程度与节点数的多少有关系, 节点越多, 分布越均匀。
可以做一个测试看看。