Re: Random mirrors and download quota
| From: | Julio Nobrega | Date: | Mon, 12 Aug 2002 00:39:57 +0000 |
| Subject: | Re: Random mirrors and download quota | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112073@lists.php.net to get a copy of this message | ||
Seems good to me, only this part:
> and it will be checked if the mirror is randomly selected and
> if it is above 1200, will randomly select another server
It's better to select those under 1200 right from the start. If you have
10 servers, you might make 9 checks before selecting the last one.
--
Julio Nobrega
Pode acessar:
http://www.inerciasensorial.com.br
"Andrew Conner" <spam@microwinder.com> escreveu na mensagem
news:20020810193011.9435.qmail@pb1.pair.com...
> Hello,
> I have a script (at bottom) that, upon loading, will randomly select a
> mirror or primary server (on average, the primary servers will be selected
> twice as much). It all works good, but now, I have to add a "quota
manager"
> that will, for both mirrors, limit the times the file can be downloaded to
> 1200 times (there is only one file being downloaded). I have thought about
> storing a text file for each of the two mirrors that shows the current
count
> of downloads, and it will be checked if the mirror is randomly selected
and
> if it is above 1200, will randomly select another server, and if it isn't,
> will just add one to it and update the file. How would I go about this, or
> is there a better way to do this?
> Thanks in advance.
> Andrew Conner
>
> The script (I know it doesn't use the best design, but it works, any
better
> ways of doing this?):
> ----------------
> <?
>
> // This array holds the servers, and has a double entry for the primary
> servers
>
> $adArr = array("åplÖrRŠa~
> æ,݇œ‘http://www.someprimaryserver.com/file.exe",
>
> "http://www.someprimaryserver.com/file.exe",
>
> "http://www.someprimaryserver2.com/file.exe",
>
> "http://www.someprimaryserver2.com/file.exe",
>
> "http://www.someprimaryserver3.com/file.exe",
>
> "http://www.someprimaryserver3.com/file.exe",
>
> "http://www.someprimaryserver4.com/file.exe",
>
> "http://www.someprimaryserver4.com/file.exe",
>
> "http://www.somemirror.com/file.exe",
>
> "http://www.somemirror2.com/file.exe");
>
> // This randomly gets a server...
>
> srand((double)microtime()*1000000);
>
> $wOne = rand(0, 9);
>
> $choice = $adArr[$wOne];
>
> // This fwds the user to the server picked.
>
> // Somewhere in here needs to be the mirror stuff...
>
> header("Location: $choice");
>
> ?>
>
>
>