• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

PHP Connecting over 'localhost' to MySQL very slow

arisd

Basic Pleskian
Hi,

Since I could not find any solution over internet (none of them helped) I must turn to other users if anyone has solution.

I have windows server 2012 and Plesk v12.0.18 #30 - I noticed speed problem.

When I try to connect to mySQL with:
$conn = new mysqli('localhost', 'joomla_***', '*****', 'joomla_test');

Connection takes 1 second
!!!

When I try to connect with '127.0.0.1' instead of 'localhost' connection takes 0,009 seconds.

1. I tried solution to add line '127.0.0.1 localhost' to c:\windows\system32\drivers\ets\hosts - but no luck.
2. I tried to edit C:\Program Files (x86)\Parallels\Plesk\MySQL\Data\my.ini - adding lines
bind-address=127.0.0.1
skip-name-resolve
then restarted mySql but 1 second lag time on connection was still there.
3. I even tried to disable IPv6 but still no luck

Has anyone of you found solution to this problem - I guess all usesr windows windows server 2012 has the same problem??!?!...

Thanks, Aris.
 
Hi,

You mean to say you added both these lines at the same time to check?
--------
bind-address=127.0.0.1
skip-name-resolve
--------
 
Hi, InderS

Thank you for answer.

I tried just now added both lines to my.ini but still no luck - lag time remains - any more ideas?...

In first post i wrote wrong my.ini path - i corrected right my.ini:
C:\Program Files (x86)\Parallels\Plesk\Databases\MySQL\data\my.ini

You can see for yourself:
http://www.bojanornik.si/joomla/test-localhost.php
http://www.bojanornik.si/joomla/test-127.php

Any more ideas? Perhaps some PHP settings to force using 127.0.0.1 instead of localhost?
 
For future reference:

Solution 1 & 2 won't work. You really need to change the preference of IPv6 over IPv4 in Windows Server 2012. That very second lag you are referring to is the delay introduced by localhost resolving to a IPv6 address. You can do this easily:

http://community.spiceworks.com/how_to/36202-disable-ipv6-through-the-registry

Use (0x)20 instead of (0x)FFFFFFFF. 20 just changes the preference while FFFFFFFF is completely disabling IPv6 which you shouldn't want to.
 
Back
Top