doitlikejustin
doitlikejustin

Reputation: 6353

MAMP running extremely slow with external database connection

I am dealing with really slow loading of pages. I used Chrome console's Network tab to get this information (but it is slow on all browsers).

I have researched the issue heavily, but now I am completely stumped. I have tried Blowski's answer to MAMP: reloading pages is very slow (editing my hosts file), but had no luck with getting the page to load faster.

I am running OS X 10.8.5, CodeIgniter 2.1.3, and connecting to a remote MySQL database (which is on the same server as the live web server). Not sure if that has anything to do with the waiting being so long. Speed tests for loading the same page are below:

localhost
Waiting time is 13.49 seconds

enter image description here

Web Server
Waiting time is 222 milliseconds

enter image description here

What can I do to fix this issue?

Update: I've narrowed down the issue to the MySQL database (which is located on a remote server, separate from where PHP (MAMP) is installed). Are there any settings I would need to change to fix this horrible load time? I am also connecting to the database using an IP address and not a domain name, so I don't believe it is a DNS issue with the server MySQL is installed on.

Upvotes: 1

Views: 3003

Answers (3)

arnekolja
arnekolja

Reputation: 1687

Could it be that the server running the MySQL daemon is configured to do reverse DNS lookups? With the development machine being your own computer on a standard ISP line this could cause a serious delay on each request, as the reverse DNS lookup has to time out every time.

Upvotes: 0

xiankai
xiankai

Reputation: 2781

For a general solution, try using a profiler - it is meant for diagnosing performance issues.

this link has a pretty good tutorial - http://geek.michaelgrace.org/2011/08/xdebug-cachegrind-and-mamp-on-mac-osx/

You should examine the results to see which function(s) take the most time of execution. I suspect your remote database connection may be at fault, but a profiler will give you definitive results.

Upvotes: 1

xiankai
xiankai

Reputation: 2781

Such a long lag makes me suspect profiling as the culprit, especially since it's only on localhost.

Check your php.ini if xdebug is enabled (it may be found in a separate xdebug.ini), and if so, if xdebug.profiler_enable is set to true/1.

That, or perhaps MAMP uses another profiler.

Upvotes: 0

Related Questions