shekhar
shekhar

Reputation: 937

MySQL - Persistent Connections (or) sleeping connections

We have few IIS servers with ASP .NET based websites. They are connected to MySQL Database. For every 2 - 3 days the MySQL Database connection pool filling with sleeping connections and we have to manually close left connection which are with status as sleeping.

Is there any way i close those persisted connections of MySQL ?

Thank you.

Upvotes: 2

Views: 1072

Answers (1)

Abdul Manaf
Abdul Manaf

Reputation: 4888

From This link , The importance of Persistent connections is as

Persistent connections are efficient because there is no overhead to make a connection between PHP and MySQL, every time a PHP script is executed. The main drawback however is that resources may be easily wasted because MySQL keeps some data of that connection in its cache, even when no PHP script is currently using the connection. A common problem are result sets of large SELECT queries that may stay in memory long after there usefulness in the PHP script that requested the data has ended. These result sets are using available resources and could be the source of the resource problem you currently see.

The proper way to deal with this is carefully calling the mysql_free_result() function whenever returned data from a SELECT statement is no longer needed. This may free up enough resources for your MySQL server to run smoothly again.

How to controll behaviour of persistent connections

the behaviour of persistent connections can be tuned in your PHP.INI file with the mysql.allow_persistent and mysql.max_persistent settings.

Upvotes: 1

Related Questions