I have not changed anything in this situation recently, but recently my mysqli_connect() to a remote server is very slow (about half the time it hits the 30 second max execution time). When it works, the response time is between 28 and 30 seconds.
I have restarted MySQL on both servers. The server holding the PHP script is a local WAMP server, the remote server is a LAMP stack. The LAMP server performs fine serving the same information that the WAMP server is requesting. The queries do not appear to be the issue, instead it looks like mysqli_connect() is the problem:
$mtime = microtime();
$mtime = explode(" ",$mtime);
$starttime = $mtime[1] + $mtime[0];
$this->conn = mysqli_connect($this->host,$this->user,$this->password) or die(mysqli_error($this->conn));
$etime = microtime();
$etime = explode(" ",$etime);
$endtime = $etime[1] + $etime[0];
$totaltime = ($endtime - $starttime);
echo('<!--mysqli_connect took: '.$totaltime.' seconds-->');
The page (when it does not give a 500 response for hitting max_execution_time) will show:
<!--mysqli_connect took: 28.975151777267 seconds-->
The same code on the remote LAMP server will show:
<!--mysqli_connect took: 0.036190032958984 seconds-->
I have not updated this code or made any configuration changes since this was working. I get no errors on either server except for the max_execution_time exceeded error when it goes past 30 seconds on the WAMP server. Does anyone have any suggestions?
Thanks for reading.