jeff, I'm surprised more projects aren't having this MySQL scaling issue in #PHP.
MYSQLI_OPT_CONNECT_TIMEOUT only affects the TCP init, not the time to first byte.
MYSQLI_OPT_READ_TIMEOUT is then also needed to time out quickly if a socket connects but sends no data in a reasonable time (DoS otherwise).
However, that also aborts queries that run longer than the limit (reports, schema upgrades).
You have to set the timeouts before a connection and can't use @@session.
Add comment