简体   繁体   English

通过外部数据库连接,MAMP运行极其缓慢

[英]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). 我使用了Chrome控制台的“网络”标签来获取此信息(但在所有浏览器中速度都很慢)。

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. 我尝试了BlowskiMAMP 的回答 :重新加载页面非常慢 (编辑我的hosts文件),但是让页面更快地加载并没有运气。

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). 我正在运行OS X 10.8.5,CodeIgniter 2.1.3,并连接到远程MySQL数据库(该数据库与实时Web服务器位于同一服务器上)。 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 等待时间是13.49秒

在此处输入图片说明

Web Server 网络服务器
Waiting time is 222 milliseconds 等待时间为222毫秒

在此处输入图片说明

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). 更新:我已将问题缩小到MySQL数据库(位于远程服务器上,与安装PHP(MAMP)的位置分开)。 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. 我还使用IP地址而不是域名连接到数据库,所以我认为安装MySQL的服务器不是DNS问题。

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/ 此链接有一个很好的教程-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. 我怀疑您的远程数据库连接可能有故障,但是探查器将为您提供确定的结果。

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. 检查您的php.ini是否启用xdebug (可以在单独的xdebug.ini找到),如果启用,则将xdebug.profiler_enable设置为true / 1。

That, or perhaps MAMP uses another profiler. 那,或者也许MAMP使用另一个分析器。

Could it be that the server running the MySQL daemon is configured to do reverse DNS lookups? 可能是将运行MySQL守护程序的服务器配置为进行反向DNS查找吗? 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. 由于开发机器是您自己的标准ISP线路上的计算机,这可能会导致每个请求的严重延迟,因为反向DNS查找必须每次都超时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM