连接到MySQL服务器(本地主机)很慢 [英] Connecting to mysql server(localhost) very slow

查看:239
本文介绍了连接到MySQL服务器(本地主机)很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实它稍微复杂一些:

摘要:为DB连接速度非常慢

summary: the connection to DB is very slow.

在页面渲染需要约10秒,但页面上的最后一句话是回声,我可以看到它的输出,而页面加载在Firefox(IE相同)。谷歌浏览器的输出变得可见,只有当装载完成。加载时间大约是跨浏览器相同的。

the page rendering takes around 10 seconds but the last statement on the page is an echo and i can see its output while the page is loading in firefox (IE is same). in google chrome the output becomes visible only when the loading finishes. loading time is approximately the same across browsers.

在调试,我发现,它的数据库连接所产生的问题。数据库是另一台机器上。进一步调试。我部署了DB我的本地机器..所以现在的数据库连接是12​​7.0.0.1,但连接仍需要较长时间。

on debugging i found out that its the DB connectivity that is creating problem. the DB was on another machine. to debug further. i deployed the DB on my local machine .. so now the DB connection is at 127.0.0.1 but the connectivity still takes long time.

这意味着该问题是与Apache / PHP和不使用MySQL。但后来我部署了我code它连接到DB另一台机器上remotely.and一切似乎都很好。

this means that the issue is with APACHE/PHP and not with mysql. but then i deployed my code on another machine which connects to DB remotely.and everything seems fine.

基本应用程序使用mod_rewrite的夫妇的..但我删除了所有的.htaccess文件和连接缓慢问题仍然..

basically the application uses couple of mod_rewrite.. but i removed all the .htaccess files and the slow connectivity issue remains..

我安装我的机器和使用默认设置,在另一个APACHE。连接仍然十分缓慢。

i installed another APACHE on my machine and used default settings. the connection was still very slow.

我添加以下语句来衡量的执行时间

i added following statements to measure the execution time

    $stime = microtime();  
    $stime = explode(" ",$stime);  
    $stime = $stime[1] + $stime[0];  

// my code -- it involves connection to DB

    $mtime = microtime();  
    $mtime = explode(" ",$mtime);  
    $mtime = $mtime[1] + $mtime[0]; 

    $totaltime = ($mtime - $stime);
    echo $totaltime;

输出为0.0631899833679

the output is 0.0631899833679

但萤火虫网面板显示的10-11秒的总加载时间。同样是与谷歌浏览器的情况下

but firebug Net panel shows total loading time of 10-11 seconds. same is the case with google chrome

我试图防火墙关闭Windows ..连接仍然缓慢

i tried to turn off windows firewall.. connectivity is still slow

和我只是不能完全找到原因.​​.我已经尝试了多个数据库服务器..多阿帕奇..没有似乎工作..的可能是什么问题的任何想法?

and i just can't quite find the reason.. i've tried multiple DB servers.. multiple apaches.. nothing seems to be working.. any idea of what might be the problem?

请通过进一步的细节注释部分。其实我认为,即时通讯越来越接近得到解决。基本即时通讯正在开发自己的框架,其中包括URL通过.htaccess文件重写。我加入一些CSS和JS文件和我注意到,多个请求被发送这些文件​​没有很好的理由(在Firefox)。我认为这个问题具有一定的相关Content-Length头火狐犯规获得这个头所以它一直等待的内容(并可能再有一个超时)..它有什么用传输编码做:分块?

please go through the comments section for further details. actually i think im getting near to get the solution. basically im working on developing a framework of my own which includes url rewriting through .htaccess files. i added few css and js files and i noticed that multiple requests were being sent for these files for no good reasons (in firefox). i think the problem is somewhat related to CONTENT-LENGTH header as firefox doesnt receive this header so it keeps waiting for the contents (and may be then there is a timeout).. does it have anything to do with Transfer-Encoding:chunked?

推荐答案

快速CGI固定的问题..感谢srisa ..只是改变了apache的运行,通过快速的CGI PHP文件

fast-cgi fixed the problem.. thanks to srisa.. just changed apache to run php files through fast-cgi

这篇关于连接到MySQL服务器(本地主机)很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆