//测试分布式算法 $ports = array('端口1', '端口2', '端口3', '端口4', '端口5'); //Memcache端口 $users = array('1000', '1001', '1002', '1004', '9803'); //登录用户 foreach ($users as $u){ $crc = crc32($u); $mod = abs($crc % count($ports)); echo "用户{$u}被分配到了{$ports[$mod]}里。<br />"; }