MySQL and MariaDB slow connection in 3.10+
Posted by: Wilson212 (---.hsd1.wa.comcast.net)
Date: March 25, 2018 08:37PM

Hello all,

I installed Wamp version 3.1.0 a few weeks back and noticed that on a project I was working on, that connecting to both MySQL and MariaDB is very slow (takes 3000ms) every 30 seconds or so. In between those 30 seconds, my pages load super fast (less than 0.03 seconds), but once that 30 seconds has passed, the next page load takes ~3.03 seconds). Using xDebug and WebGrind, I narrowed it down to the PDO database connector:

Image: [prntscr.com]

I do not use localhost as a connector in my project. I connect using IP
"mysql:host=127.0.0.1;port=3306;dbname=stats;charset=UTF8"

This happens with both the stock WAMP settings for MySQL and MariaDB, and after any and all changes I have made to those config files. I should note that I am using Windows 10, 64 Bit with Wamp 3.13 x64 as well. PHP version 7.19 and 7.2.3.

phpMyAdmin also suffers from this too!

Does anyone have a clue why this is happening, and what can I do to fix this?



Edited 2 time(s). Last edit at 03/25/2018 08:48PM by Wilson212.

Options: ReplyQuote
Re: MySQL and MariaDB slow connection in 3.10+
Posted by: Otomatic (Moderator)
Date: March 25, 2018 08:41PM

Hi,

Don't use "localhost" as host, use IP 127.0.0.1.

And make sure you've got it:
::1 localhost
in the Windows hosts file.
Both MySQL and MariaDB most often seek to connect over IPv6.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 03/25/2018 08:43PM by Otomatic.

Options: ReplyQuote
Re: MySQL and MariaDB slow connection in 3.10+
Posted by: Wilson212 (---.hsd1.wa.comcast.net)
Date: March 25, 2018 08:42PM

I do not use localhost as a connector in my project. I connect using 127.0.0.1::3306

"mysql:host=127.0.0.1;port=3306;dbname=stats;charset=UTF8"



Edited 2 time(s). Last edit at 03/25/2018 08:45PM by Wilson212.

Options: ReplyQuote
Re: MySQL and MariaDB slow connection in 3.10+
Posted by: Wilson212 (---.hsd1.wa.comcast.net)
Date: March 25, 2018 08:49PM

I added ::1 to the hosts file, flushed the windows DNS by going <cmd -> ipconfig /flushdns> and also restarting WAMP dns server <right click W -> Tools -> Restart DNS> and it still takes 3 seconds to connect.

Options: ReplyQuote
Re: MySQL and MariaDB slow connection in 3.10+
Posted by: Otomatic (Moderator)
Date: March 25, 2018 08:59PM

Hi,

There are no parameters requiring MySQL or MariaDB disconnection after 30 sec in Wampserver.

For my local sites (sorry in French)

Page en 0,0162 secondes, connexion MySQLi en 0,0156 sec, 4 requêtes
Page en 0,0312 secondes, connexion MySQLi en 0,0156 sec, 5 requêtes
Page en 0,1404 secondes, connexion MySQLi en 0,0156 sec, 14 requêtes
Page en 1,8720 secondes, connexion MySQLi en 0,0156 sec, 113 requêtes

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.