wamp
wamp

Reputation: 5949

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

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.

Upvotes: 2

Views: 776

Answers (2)

vicenteherrera
vicenteherrera

Reputation: 1492

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()

Upvotes: 2

anon
anon

Reputation:

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.

Upvotes: 0

Related Questions