ADO and msqli connections very slow

独自空忆成欢 提交于 2019-12-11 00:42:33

问题


I am experiencing a very slow ADO and mysqli connection for my production web server. The current software setup is windows 2008 server R2 Standard Edition SP1, Apache 2.4, PHP 5.3.10, MySql 5.5.24, Pear 1.94, Zend Engine version 2.30.

I've profiled the code using XDEBUG and it shows the initial connections taking around 1200ms each (regardless of page being visited), whereas on my local development machine and another test server the connections only takes around 8ms. The code for the website is all in sync through SVN except for the php, pear, mysql, and apache ini and conf files. I've done diffs on these to check for differences and there aren't any. The DB contents are a complete copy as well. Everything for the production server is hosted on the same machine so there aren't any firewall or internet issues.

The first connection profile has the following call stack:

ADOConnecton->Connect
ADODB_mysql->_connect
php::mysql_connect

The second one:

php::mysqli->mysqli

Any suggestions?


回答1:


Usually the slowness in (first) connection depend on DNS resolution. May be:

  • client to resolve the server name
  • server to resolve the client name to match an access rule

let the client/server let know the server/client address using the host file: http://en.wikipedia.org/wiki/Hosts_(file)




回答2:


I edited the Mysql my.ini to change the mysql service to only bind to the IPV4 loopback adapter.

[mysqld]
...
bind=127.0.0.1

I also changed the \public_html\conf\face.ini to use the IPV4 loopback address instead of local host. (Changed "localhost" to "127.0.0.1")

After that all issues went away. I'm not sure if it is because the machine has a half dozen IP addresses or its trying to decide whether to use IPV6 or IPV4.



来源:https://stackoverflow.com/questions/11140975/ado-and-msqli-connections-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!