network connections
| From: | J.R. Lillard | Date: | Fri, 07 Sep 2001 16:26:24 +0000 |
| Subject: | network connections | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-66430@lists.php.net to get a copy of this message | ||
i've got a command-line php script that i've been using to deliver large amounts of e-mail. originally it relied on mail() to deliver the messages but i could easily overload sendmail and bring the box (redhat 7.1) to a crawl. so i am now using the various network functions to speak smtp directly from the script. i seem to be having a problem with an excessive number of tcp connections that eventually brings down the machine.
i have attempted a semi-multi-threaded approach by spawning off additional copies of the script to deliver more mail simultaneously. so i might have 100 copies of the script running at the same time. and this was after dumping a million messages into my mysql-based mail queue. things may run okay for a few hours...maybe even a day...but then doing a netstat shows over 10k tcp connections. and the only way i've found to fix the problem is to reboot the machine.
thinking that i was attempting too many connections at the same time, i throttled down the number of threads to 25. this slowed down my mail delivery of course. and it allowed the machine to stay up longer. but i eventually ran into the same problem after maybe two or three weeks. just before it died, i was showing over 30k tcp connections.
are they any known issues in the php networking code that would cause this to happen? as far as i know, i should never have more than 25 tcp connections open. but i'm not sure if they are not being closed properly or what.
--
-jr