views:

20

answers:

1

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?

+1  A: 

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.

Brent Baisley