本地mysql连接慢,连接到MySQL服务器(本地主机)很慢

actually its little complicated:

summary: the connection to DB is very slow.

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.

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.

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.

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

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;

the output is 0.0631899833679

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

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?

[edit]

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?

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值