|
|
| Think about Loose Coupling | |
| PerlMonks |
Re: Help, please - MySQL database error - too many connectionsby CountZero (Bishop) |
| on Sep 25, 2007 at 19:57 UTC ( [id://641030]=note: print w/replies, xml ) | Need Help?? |
|
I had the same problem too and adding more connections is definitely NOT the way to solve this. What you need is Apache::DBI which will manage a pool of persistent connections for you. Now every new request will not start a new connection but will re-use an existing connection, which will cut down your number of connections to the maximum number of concurrent requests which access the database, rather than adding a new connection for each such request (and they will only disappear once the time-out value expires, meaning you will quickly run out of free connections). Another solution is set the time-out value to a very short period of time (thus freeing more quickly your connections) but that has the drawback that you need to re-connect frequently and that will cost precious time. CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||