开发者

mysqli_real_connect() often takes around 5 seconds,even on developing environment

开发者 https://www.devze.com 2023-01-11 19:20 出处:网络
mysqli_real_connect($connection, $url[\'host\'], $url[\'user\'], $url[\'pass\'], substr($url[\'path\'], 1), $开发者_运维问答url[\'port\'], NULL, MYSQLI_CLIENT_FOUND_ROWS);
mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $开发者_运维问答url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS);

What's the reason that it can take much time to make a connection?

Now about 3 out of 8 connections will hang for 5 seconds or even more.


Maybe you are connecting to the MySQL server using a domain name, and the DNS resolution takes too much time.

There is a similar question that was addressed by using IP for the conection, but the waiting time in that case was in the order of milliseconds, take a look at it at: Retrieve how long it takes to establish a connection with PHP mysqli_real_connect()


I think your mysql server is overloaded. you can try raising your 'max_connections' in my.cnf . also check your logs for any helpfull information.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号