PDO "localhost" is very slow

I installed a local server using "Uniform Server Z". It satisfies my needs better than WAMP and XAMPP.

I am very pleased with this, except for 1 thing - it is very slow. It takes more than 2 seconds between request and loading for any of my web pages.

I realized that if I use "127.0.0.1" to connect to my mysql database (using PDO), it is much faster (query time from ~ 2 s to 5 ms)

I can’t understand why it has been allowing "localhost" for so long. If I ping 'localhost', it takes <1ms. I assume Uniform Server Z should have a setting that is different from the WAMP and XAMPP settings.

  • I tried "HostnameLookups Off" in httpd.conf and "skip-name-resolve" in my.ini.
  • I tried to return my hosts file back to just 127.0.0.1 localhost.
  • I tried to remove all instances of VirtualHosts in apache confs.
  • I do not use .htaccess.
  • If I use 127.0.0.1 in my web address bar in Chrome. I get the same results.

None of what I tried worked.

I know that the obvious answer replaces "localhost" with "127.0.0.1", but there are third-party php scripts used by my site that link to "localhost" and some to "127.0.0.1". I would prefer to leave them as they are.

Can anyone think of other settings that might solve the problem?

+4
source share

Source: https://habr.com/ru/post/1608062/


All Articles