4m1nh4j1
4m1nh4j1

Reputation: 4356

mysql.connect_timeout in php vs connect_timeout in MySQL

What is the difference between :

mysql.connect_timeout   

that we can find in php.ini

and

connect_timeout

that belongs to MySQL configuration (show variables).

Knowing that Apache server and MySQL server are two distant VPS with a VIP between them, what is the value considered by the whole environment (Varnish + Apache + MySQL)?

Upvotes: 8

Views: 12471

Answers (2)

Barmar
Barmar

Reputation: 781028

mysql.connect_timeout tells PHP how long it should wait for a response from the MySQL server when it tries to connect.

connect_timeout in MySQL configuration tells the MySQL server how long to wait for a connect packet from the client before responding with a Bad handshake error.

Apache is not involved in either of these timeouts, they're just between PHP and MySQL. First PHP connects to MySQL; if it doesn't get a response before mysql.connect_timeout, it will report an error. Once that succeeds, PHP sends a connect packet to MySQL; if it doesn't do that within connect_timeout, MySQL will report an error and close the connection.

Upvotes: 12

Paul Frederiksen
Paul Frederiksen

Reputation: 384

The shortest timeout within the stack would be essentially act as your timeout. If you hit a timeout, the longer timeout will never get hit, so it won't matter.

Upvotes: 0

Related Questions