I created a simple PHP test page that connects to a MySQL database, selects a single int value and then frees the result. It takes 5 seconds or more to download. I have seen many posts about this or similar issues, but not about resolutions. Here is the result I get:
mysql_connect took 4.8948628902435 seconds mysql_select_db 0.00073790550231934 seconds mysql_query took 0.0013959407806396 seconds mysql_free_result took 2.0980834960938E-5 seconds
As you can see, the connection takes too much time, and everything else is fast.
What i tried
- Disabled IPv6
- Used IP instead of FQDN for MySQL host.
- Change the configuration settings.
Data
- All other non-PHP sites react instantly.
- MySQL pinging server gives 1 ms latency.
- Querying a database using MySQL Query Browser gives instant response time.
FYI - I do not do PHP, so it’s good to treat me like a child, offering corrections.
Test script
<?php $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; mysql_connect("the_ip||the_hostname", "the_username", "the_password"); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo '<h2> mysql_connect took ' .$totaltime. ' seconds</h2>'; ?>
Route tracing is instant: By the way, this is the MantisBT application, as well as Wordpress.
1 2 ms <1 ms <1 ms 1.2.3.4 2 <1 ms <1 ms <1 ms MYSQL5 [5.6.7.8]
source share