hacker has asked for the wisdom of the Perl Monks concerning the following question:
my @mirrors = ( 'http://foo.mirror.org', 'http://www.users-domain.com/proj/foo', 'http://osdn.dl.sf.net/sourceforge/foo', 'http://unc.dl.sf.net/sourceforge/foo', 'http://umn.dl.sf.net/sourceforge/foo', 'http://heanet.dl.sf.net/sourceforge/foo', 'http://aleron.dl.sf.net/sourceforge/foo', ); print $cgi->a({-href => "$mirrors[rand @mirrors]/$file-$stable.rpm", -title =>"$stable RPM"}, 'rpm');
So far, this works for randomizing the links we have on our download page. What I'd like to do though, as some mirrors have a throttling limit and a monthly bandwidth quota enforced by their providers, is find a way to "weight" the randomization, so that some of the elements in @mirrors are chosen "more often" than the others. In the example pseudocode above, the Sourceforge mirrors would be weighted higher than the users' home DSL connections who are helping out by being "part-time" mirror sites.
What is the best way to go about handling this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weighting rand()
by EdwardG (Vicar) on May 25, 2004 at 08:02 UTC | |
|
Re: Weighting rand()
by BrowserUk (Patriarch) on May 25, 2004 at 08:13 UTC | |
by EdwardG (Vicar) on May 25, 2004 at 08:24 UTC | |
by BrowserUk (Patriarch) on May 25, 2004 at 08:42 UTC | |
by Abigail-II (Bishop) on May 25, 2004 at 09:10 UTC | |
by dave_the_m (Monsignor) on May 25, 2004 at 10:46 UTC | |
by BrowserUk (Patriarch) on May 25, 2004 at 11:30 UTC |