I have a PHP script that connects to MySQL does some operations and ends.
At the end there is a mysqli_close($link);
statement.
Still I have sleeping processes for that user in MySQL process-list and can't figure out where from?
As far as I know as soon as the PHP script ends it should close the connection even without a mysqli_close
at the end (but there is one).
So where are those sleeping processes from on that user?
If I restart httpd
they all die.
mysqli provides persistent connections. That is, it provides a layer between the PHP developer's model of connections and the dbms's model.
When you use persistent connections a PHP program closes a connection with mysqli_close()
. But, the connection to the DBMS is maintained by the PHP runtime ready for the next open call.
This provides an enormous speedup on busy web sites, because opening a connection from the PHP runtime (or any other dbms client) and the dbms is expensive.
Your nice round number of idle connections (ten of them) smells a lot like a persistent connection pool to me.
Could this be the explanation for what you are seeing?