Jump to content

PHP Fork: Too Many Connections


jkds

Recommended Posts

Hi all,

 

I'm forking PHP, and creating a new MySQL connection with each child process using mysql_connect (NOT pconnect). This new connection creation method is necessary to get round the "MySQL server has gone away" issue commonly found with PHP forks.

 

Thing is, the connections aren't closing, eventually resulting in a "Too many connections" error. The "show processlist" command displays lots of connections with the command showing as "Sleep".

 

Each child process ends with the following code:

 

//close the connection
mysql_close($childconns[$connid]);
//end child
posix_kill(getmypid(),9);
exit();

 

..but to no avail - the connection remains open.

 

I've reduced the wait_timeout variable in MySQL to 300, which solves the problem. BUT some of these child processes may take a long time (like, 20 minutes plus... they're FTP uploads), and so will lose their database connection (I assume).

 

So my question is: can anyone help me kill my PHP children?!

 

Thanks!

 

PS. Apologies if this is posted in the wrong place - bit of a cross-forum issue...

Link to comment
https://forums.phpfreaks.com/topic/182281-php-fork-too-many-connections/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.