[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: MySQL is eating up my RAM



[Please don't top quote!  It makes your message harder to read,
especially in long threads.]

On Thu, Feb 27, 2003 at 12:01:05PM +0800, louie miranda wrote:
> > Check the PHP scripts that are accessing your server.  If they are 
> > using the "mysql_pconnect" function (persistant connections) to 
> > connect to the database, tell them to use "mysql_connect" instead.
> > Persistant connections can cause problems like you describe because 
> > they will sometimes not be closed and clog up the mysql server.
> 
> Do mysql_pconnect really never close its connection? or sometimes
> it closes, but in general its sometimes do not close its connection
> goint to mysql?

AIUI, each of these persistent connections is associated with an apache
worker process.  The number of open connections will gradually increase
until it hits apache's MaxClients directive as a hard limit.  Since
apache processes are killed off every now and then (to stop memory leaks
causing too much trouble), you'll be able to grab a connection to the
MySQL DB at some point, if you keep trying really quickly :)

Of course, the real solution to all this is to crank up the number of
simultaneous connections that MySQL will accept to something higher than
apache's MaxClients.  If MySQL can't handle this, it's a bug and you
either need to fix it or switch DBs :P

-- 
Rob Weir <rweir@ertius.org>				http://ertius.org/

Attachment: pgpwLW8oEZl3R.pgp
Description: PGP signature


Reply to: