|
Posted by Floortje on 05/27/07 18:17
alpha.beta0@googlemail.com wrote:
> I have a MySQL table of servers, I use RAND() to pick a random server
> to use each time, but how can I add a number to each server entry that
> allows it be to picked more often than the other 20 servers?
>
> For example Server1's weight is 80 and Server2's weight is 40 and
> hence Server1 is more likely to be picked than the others.
>
I dont think myqsl can do that (corect me if im wrong please)
If the weights aren't too large i would solve it something like this:
Offcourse this will get verry ineffective if a=1,b=100000000, etc
link->weight
a->1
b->3
c->2
->select all links
->create a new array $w=(a,b,b,b,c,c)
and voilla
$link=$w[rand(1,count($w))];
--
Arjen
http://www.hondenpage.com - mijn site over honden
Navigation:
[Reply to this message]
|