I need to find a way to detect whether a website (a joseki end point) is overloaded or not. http://128.250.202.125:7001/joseki/oracle is always up, but when I submit a query, sometimes it is idling. (i.e. overloaded, rather than it is down)
My approach so far is to simulate a form submission using curl. if curl_exec return false, I know the website is overloaded.
The major problem is that I am not sure whether website overloading triggers 'FALSE return' or not. I can log the curl_exec's return using this method, but this the website going down.
<?php
$is_run = true;
if($is_run) {
    $url = "http://128.250.202.125:7001/joseki/oracle";
    $the_query = "
PREFIX dc:    <http://purl.org/dc/elements/1.1/>
PREFIX rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:   <http://www.w3.org/2001/XMLSchema#>
PREFIX owl:   <http://www.w3.org/2002/07/owl#>
PREFIX fn:    <http://www.w3.org/2005/xpath-functions#>
PREFIX ouext: <http://oracle.com/semtech/jena-adaptor/ext/user-def-function#>
PREFIX oext:  <http://oracle.com/semtech/jena-adaptor/ext/function#>
PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#timeout=100,qid=123>
SELECT ?sc ?c
WHERE 
  { ?sc rdfs:subClassOf ?c} 
    ";
    // Simulate form submission.    
  $postdata = http_build_query(array('query' => $the_query));
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $tmp_condi = curl_exec($curl);
    // After I submit a simulated form submission, and http://128.250.202.125:7001/joseki/oracle is
    // not responding (i.g. idling), does it definitely returns FALSE????
  if($tmp_condi === FALSE) {
    die('not responding');  
  }
    else {
    }
  curl_close($curl);
}
Solution
Able to solve it by adding the following, based on this: Setting Curl's Timeout in PHP
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); 
curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds
 
     
     
    