Ben
Ben

Reputation: 62494

How do I track overhead of establishing/closing mysql connections

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?

Upvotes: 2

Views: 250

Answers (1)

Brent Baisley
Brent Baisley

Reputation: 12721

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.

Upvotes: 2

Related Questions