|Syntactic Confectionery Delight|
Selecting the "fastest" server listed in an arrayby hacker (Priest)
|on Sep 11, 2007 at 00:10 UTC||Need Help??|
hacker has asked for the wisdom of the Perl Monks concerning the following question:
Previously, I was putting our external mirrors in an array called @mirrors, and rendering the page based on:
This breaks down when one of the mirror sites is either down, offline or inaccessible.
I'm rewriting the entire site, and wanted to do this in a more-intelligent way, by checking if the remote mirror is accessible before I write those links into the page for the end users. I can do this by using LWP and a HEAD request, checking $response->status_line; for a 200 response code like this:
I'd like to take that one step further, and present the user with the FASTEST server hosting our releases. In Debian, there is a tool called 'netselect', and another one that uses it called 'netselect-apt'. The combination of these will pick the fastest Debian mirrors to your current location, and build a sources.list file for you.
Is there some way to do this with LWP or other magical incantations? Some method that will check the array for the fastest response time, and use that entry over any others?