New User? Register here - Existing Users: Username: Password: [Advanced Login]

 

 

Current Poll

Your preferred Interactive shell?









( 1387 votes ~ 15 comments )

 

Weblog entry #246 for simonw

MySQL Persistent Connections in PHP
Posted by simonw on Tue 6 May 2008 at 15:11
Tags: none.
The switch for disabling these for PHP scripts is not "mysql.cnf" as some non-Debian hints suggest but "/etc/php5/apache2/php.ini" on Debian (adjust for PHP and Apache versions as applicable).

You might consider this if you seem to accumulate a lot of lurking MySQL processes from web applications that use the pconnect call in PHP, and you thus hit problems with too many connections.

mysql.allow_persistent=Off

Similar setting can be set for various different databases (Postgres, ODBC etc).

Persistent connections allow a resource optimisation, but allowing them permits users to more easily hit the resource constraint "Too many connections in ...", depending on programmer skill.

Unless the same database connections are heavily used, disabling it makes the system administrators life easier (and in our case things run faster, probably as the so many fewer tasks have to be scheduled!). So assume your PHP programmers are brain dead, and disable it till you learn otherwise, and life may be better.

In this instance I am probably the brain dead PHP programmer, although there are a lot of clueless PHP programmers so it might not have been me, and this was in generated code anyway so I probably clicked the wrong button in a point and drool tool somewhere.

This is a note for self. If I understood all this - I wouldn't have hit this problem.

 

Comments on this Entry

Posted by trollll (67.102.xx.xx) on Wed 7 May 2008 at 04:27
[ Send Message | View Weblogs ]
In your mysql.cnf, what value do you have for max_connections? It defaults to a fairly low number (I think 100), so you can probably up it a bit.

See http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html for more info. From the page:

"The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform. Linux or Solaris should be able to support 500-1000 simultaneous connections, depending on how much RAM you have and what your clients are doing. Static Linux binaries provided by MySQL AB can support up to 4000 connections."

[ Parent | Reply to this comment ]

Posted by Anonymous (193.192.xx.xx) on Mon 2 Nov 2009 at 10:15
ILOGOS's main focus is professional software engineering and the company's expertise covers all major IT engineering areas for: IT-companies, Software outsourcing companies, IT-departments, IT-specialists. So, having learned your business, we mean and hope that our companies have common interests and common business opportunities.
We are ready to propose offshore development for your company at hourly rates 10-15euro.
Fulfilled projects - http://ilogos-ua.com/projects.shtml
All our services - http://ilogos-ua.com/service.shtml

[ Parent | Reply to this comment ]

 

 

Flattr