Solved

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

Posted on 2004-10-05
3
229 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now