Search code examples
phpcodeignitercurluptimescalable

What's the Best method of checking Site / Server Uptime Efficiently (PHP)


I am trying to build a system of monitoring site / server uptime in PHP, the system will be required to check thousands of domains / ips a minute. I have looked into cURL as this seems to be the best method.

Edit: The system will be required to probe a server, check its response time is reasonable, and return its response code. It will then add a row to a mysql db containing response time and status code. The notification part of the system is fairly straight forward from there. The system will be on dedicated servers. Hope this adds some clarity.


Solution

  • Why not go for the KISS approach and use php's get_headers() function?

    If you want to retrieve the status code, here's a snippet from the comments to the php manual page:

    function get_http_response_code($theURL) {
      $headers = get_headers($theURL);
      return substr($headers[0], 9, 3); 
    }
    

    This function (being a core php feature) should be faster and more efficient than curl.