carp协议

http://icp.ircache.net/carp.txt

 

对url做hash

 

For (each char in URL):
	URL_Hash +=  _rotl(URL_Hash, 19) + char ; 
 
 对proxy做hash 
 

 For (each char in MemberProxyName):
	MemberProxy_Hash +=  _rotl(MemberProxy_Hash, 19) + char ; 
MemberProxy_Hash += MemberProxy_Hash * 0x62531965 ;
  MemberProxy_Hash = _rotl (MemberProxy_Hash, 21) ;
合并url和proxy的hash
Combined_Hash = (URL_hash ^ MemberProxy_Hash) ;  
  Combined_Hash += Combined_Hash * 0x62531965 ; 
  Combined_Hash = _rotl(Combined_Hash, 21) ; 
 
计算负载因子
 
All X_n values are 32 bit floating point numbers.

  X_1 = pow ((K*p_1), (1/K))

  X_k = ([K-k+1] * [P_k - P_{k-1}])/(X_1 * X_2 * ... * X_{k-1})
  X_k += pow ((X_{k-1}, {K-k+1})
  X_k = pow (X_k, {1/(K-k+1)})

  where:

  X_k = Load Factor Multiplier for proxy k
  K = number of proxies in an array
  P_k = relative percent of the load that proxy k should handle
 
计算最终得分
Resultant_value = Combined_Hash * X_k
 
路由选择
得分最高的url和哪个proxy计算得分最高,这个url就被路由到哪个proxy。
 
增减proxy时,url落点的迁移量为1/N, N为proxy数目。
 

 


你可能感兴趣的:(url,each)