PHP - check if file exists on a remote server

Posted by Gigaron, 01-16-2008, 03:08 AM
I have my static files duplicated and spread over multiple servers. I have a piece of code to randomly select a number out of 4 where each number is assigned to a different server location. When the user downloads the file it randomly downloads from 1: http://server1.com 2: http://server2.com 3: http://server3.com 4: http://server4.com In the case a server is down or is too slow to respond, is here a way to do a quick check network check, remote file exists check, and/or speed check and thus removing the server out of the pool of 4 random numbers.

Posted by Steve_Arm, 01-16-2008, 04:27 AM
Use php.net/curl functions

Posted by webbo34, 01-17-2008, 09:44 AM
Curl would be the best option, but you can still use "fopen" on a URL. You could also use sockets - "fsockopen" is a good place to start. Webbo

Posted by cygnusd, 01-17-2008, 10:09 AM
From the way I see it, you are load balancing the static file servers. I suggest you to use a high-performance reverse proxy for that job. For me, the best tool suited for that is Perlbal (http://www.danga.com/perlbal/). It has the a good implementation of load balancing and failover.

Posted by Harzem, 01-17-2008, 10:27 AM
Assuming you run PHP , Check the port 80 via "fsockopen". Then, read an example file to see if the server is working. test.php on server1.com: And test it via your central server:

?האם התשובה שקיבלתם הייתה מועילה

 הדפסת המאמר

קראו גם

how to cron on windows server?

Posted by waveking, 05-03-2007, 10:04 AMHi, I truly love the 'cron' feature on Linux servers....

Any PHP library to create .ico? Or just to convert a PNG to ICO?

Posted by yangyang2036, 09-21-2008, 09:17 PMSearched google with nothing relevant. Posted by...

Scheduling Software

Posted by raulgonzalez, 01-15-2008, 07:30 PMHello, Does anyone know of an opensource software...

subdomain and directory question

Posted by azn_romeo_4u, 03-27-2008, 01:02 AMHow do those websites do a website like this....

PlanetDomain API - Frustrating - Waiting for almost a decade!

Posted by MrLeN, 09-21-2008, 10:55 AMI have been a PlanetDomain reseller for about 8 years or so...