Solved

linux/redhat: mailing list (sendmail) hangs after approx. 5 min running

Posted on 2004-10-05
3
231 Views
Last Modified: 2010-04-22
Configuration:
Operating System: RedHat 7.2
Processor: Athlon XP 1800+
RAM: 512 MB
Hard Drive: 60 GB IDE
Bandwidth: 500 GB

I have a php mailing list manager that loops through a send routine, picks email addresses from a MySQL db and sends the message to each one. I have a problem where it will send to approx the first 1000 addresses then just stop, leaving the other 1000 or so address in the send que. The time it runs is approx. 5 min before it stops.

To do some testing, I commented out the sendmail lines and instead piped the output to a log file. The routine completed without a problem. I checked the time limit in the php_ini file that limits the time a script can run, and that doesn't seem to be the problem either. The log-to-file test ran for about 10 min without stopping.

My theory: The script hangs because the script is feeding commands to the system faster than sendmail can actually send, so memory is filling up and it just quits after a certain point. So, the issues has to do with memory or the buffer somehow. Maybe I need more than 500 megs of ram for this to work. That's my best guess.

Possible fix: Send in chunks of 50 every x seconds, and give the system time to "catch up" before sending more.

Note: In actual timing tests, it sends 10 per sec with mail(), and 12 per sec using the raw socket to send.
0
Comment
Question by:arievandenberg
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 500 total points
ID: 12233063
You might  be feeding messages to sendmail fast enough to reach a load average where it ceases to attempt immediate delivery (QueueLA which defaults to 8). The second limit is the load average at which Sendmail stops accepting SMTP connections (RefuseLA which defaults to 12).

The simple solution to this is to throttle the rate of message submission by placing a wait of some seconds in between each message submission. The more complex and smarter way is to monitor the mail queue depth and load average and submit messages at a rate that keeps both within reasonable limits.
0
 

Author Comment

by:arievandenberg
ID: 12259396
I think this will get me on the right path to correct the issue. I won't have a chance to test this for a while. In terms of monitoring the queue depth, is there a php routine that can do this. If so, I could probably do an if...then statement within the send routine. Thanks.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 12259905
I don't know of any "off-the-shelf" routines for doing this. When I've needed this in the past I've done it by writing a Perl script that does whatever checks I want and returns a count of permissible messages (0-n). Then I call that via system() in the PHP code. The php code can then use the returned count as the messages to queue up. Since the mail queue is only accessable by root on most modern system doing the work in an external script or progam allows that external tool to be suid to root without undue risk.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question