-1

Liquidweb hosts my site, they have a strict 30 second timeout policy if a signal isn't sent to the load balancer. My SQL query takes ~34 seconds to process when I directly access the DB.

My php looks like this:

echo " "; //To keep the site alive
$results = $this->db->query($sql); //Takes longer than 30 seconds
echo " "; //To keep the site alive.

Liquidweb cannot change the 30 second limit and the DB being queried is a membership database of tens of thousands of rows and will only get bigger.

Is there a way to have the page send a signal to the load balancer while the SQL query is running in the background?

Pallieguy
  • 63
  • 5
  • 1
    Yes, you can - https://stackoverflow.com/a/5415754/296555. There are lots of options here, but the first one should be to look at why your query is taking more than 30 seconds. Tens of thousands of rows isn't a very big dataset. – waterloomatt Aug 11 '20 at 18:24
  • This isn't really a related question. Which dbms are you using? – jarlh Aug 11 '20 at 18:46

1 Answers1

0

you can send mysql query request to dev\null and store data in file? then after 35s timeout fetch file via ajax

for exemple

    ob_start();
    $size = ob_get_length();
    header("Content-Encoding: none");
    header("Content-Length: {$size}");
    header("HTTP/1.1 200 OK");
    header("Connection: close");
    ob_end_flush();
    ob_flush();
    flush();

    $results = $this->db->query($sql);
    $fo = fopen('path_to_file', 'a+');
    fwrite($fo, json_encode($result));
    fclose($fo);

after timeout fetch this file to frontend via AJAX