Jump to content

Local dev server running slow? This may be of help.


MikeB
 Share

Recommended Posts

I have been seeing slower and slower response times on Processwire and Drupal sites on my local Xampp server for a while now. Just spent a couple of hours searching for some hints/fixes.

Thought I would share this here as the answer I found that worked for me was reported on Wampp as well and using Joomla and Wordpress so seems to be across the board.

I am running Windows 8.1 64bit. That seems to be where the issue stems, and has to do with a bug in that operating system with how they handle IPV6 first then fallback to IPV4.

The way this manifests is frequent calls to the database being repeated, increasing server response times.

So the fix is as follows.

In phpMyAdmin\config.inc.php change $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = '127.0.0.1';

This one I did not actually need as Xampp had that already, but according to the thread I found Mampp did need it.

Next uncomment bind-address="127.0.0.1" in mysql\bin\my.ini

And finally the real culprit, in Processwire site\config.php change the database configuration from $config->dbHost = 'localhost'; to $config->dbHost = '127.0.0.1';

This same applies for any CMS config file that connects to a MySQL database. (Maybe even any other database too as the issue is with OS)

And hey, WOW!! my local dev sites are running way faster now.

Hope all that is clear, and useful if anyone else is seeing slow response times locally.

Just in case here is my current setup details.

Windows Version: Windows 8 Enterprise  64-bit
XAMPP Version: 1.8.3

Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9

MySQL Community Server (GPL) 5.6.16

libmysql - mysqlnd 5.0.11-dev

phpMyAdmin Version information: 4.1.6

  • Like 4
Link to comment
Share on other sites

Sorry, but just to clarify: And finally the real culprit is the person who has added it to the config when the installer has asked for informations how to access the DB.

:lol:

What I want to say is that there are more cases possible than only "localhost". (e.g. another hostname, an IP, different than 127.0.0.1, regardless if you run a mysql server on the same machine or another, etc).

But it is really helpful to add information here that changing a named host, e.g. "localhost", to a IPv4, e.g. "127.0.0.1" can help speed up things on systems that are configured to use IPv6 at first.

Many thanks, and sorry for kidding.

Edited by horst
Link to comment
Share on other sites

No problem, and yes I agree with everything you say.

The point of this "fix" was specifically for Windows 8/8.1 OS not anything else, where 'localhost' is legitimate and causes no issues. When I said culprit I meant the actual thing that fixes the issue.

This is a bug in Windows 8/8.1 only as far as I have been able to find out.

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

I think you're a spammer. If you were using ProcessWire, you would know where the configuration file is...

Maybe... Or maybe I am from another country and I do not understand so well English.

Besides he was talking about Drupal.

Anyway thank you very much for your valuable comment.

Link to comment
Share on other sites

Maybe... Or maybe I am from another country and I do not understand so well English.

Besides he was talking about Drupal.

Anyway thank you very much for your valuable comment.

Apologies - I came to that conclusion because it is your first post. (Maybe introducing yourself in that post would have helped.)

That aside, welcome to the forums. :)

Link to comment
Share on other sites

  • 3 months later...

I do need to express my deepest sincere thanks for your post! It save me.

Although i am not running processwire, I spent dayssss in solving my problem and finally read your post and my problem is solved. (you can imagine how desperated i am as i even have no idea of what processwire is)

My config: XAMPP, windows10, mysql, drupal

I tried numerous different settings (host file, various cache methods, ip4, turnoff firewall, etc), but it still takes more than 20secs for waiting server response.

Finally, after i followed your suggestion of fixing by " uncomment bind-address="127.0.0.1" in mysql\bin\my.ini", now server response down to 1.4 second!

Wish someone out there in the internet who encounters similar problem (slow drupal server response) can read this post.

Thanks very much again.

(P.S. i also have no idea where site\config.php  and  $config->dbHost are located in my system)

Link to comment
Share on other sites

(P.S. i also have no idea where site\config.php  and  $config->dbHost are located in my system)

Firstly welcome to the forums. 

These are processwire specific settings / files, so it's perfectly reasonable why you don't know them.

Link to comment
Share on other sites

Keep following your concept, i just modified the database configuration at my below file

drupal\htdocs\sites\default\settings.php

at $database array, i changed 'host' => 'localhost' to 'host' => '127.0.0.1'

the server response time further shorten to 200ms now!!

Thanks very much again. 

PHP/5.6.12
Windows10 (64bit)
XAMPP for Windows 5.6.12
Apache/2.4.16 (Win32)
Drupal 7.43
Link to comment
Share on other sites

  • 1 year later...

MySQL usually listens to loopback interface (127.0.0.1) and only responds to requests coming from the machine itself, like PHP or NodeJS etc (unless you're using a convoluted multi-server DB architecture and have configured PW to connect another machine on the network).

So you dont have to change 127.0.0.1 to localhost. In fact leaving it that way will eliminate a (non-zero but very small) delay caused resolving host names to their IP addresses.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...