I’m trying to determine if I should be using persistent connections or not. How can I track the overhead of establishing/closing mysql connections in PHP?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should read this http://www.php.net/manual/en/features.persistent-connections.php
Persistent connections can be very bad with PHP since PHP itself is not persistent in it’s typical setup. What ends up happening is that the Apache processes ending keeping the DB connections open, but not used. So you end up having lots and lots of DB connections doing nothing. Usually you end up hitting the max connections you set for mysql.
Basically, unless the connection between your web server and db is very slow (and it shouldn’t be), don’t use persistent connections. As illogical as it sounds.