cancel
Showing results for 
Search instead for 
Did you mean: 

Limit number of Messages

SOLVED
Go to solution
David Crowe
Advisor

Limit number of Messages

Is there some way to limit the number of messages that Sendmail will send per connection? I am looking for a way to load balance traffic across a number of internal SMTP gateways. At the momemt when the connection is made Sendmail sends all that it has to that particular internal SMTP gateway. I would like to limit the number of email per connection so that once it reaches that magic number it will drop the connection and then when it re-establishes a new connection it will be made to a different internal gateway.
8 REPLIES
Stefan Farrelly
Honored Contributor

Re: Limit number of Messages

There is an option in your /etc/mail/sendmail.cf file to throttle back sendmail to a single thread;

# single thread deliveries (requires HostStatusDirectory)?
#O SingleThreadDelivery

Uncomment the last line and restart sendmail.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Mister_Z
HPE Pro

Re: Limit number of Messages

David,

you may control the message flow depending on the system load using two parameters in /etc/mail/sendmail.cf:

# Queue-Only Load Average (option QueueLA): #
# #
# In order to limit load on a very busy system, sendmail can be #
# configured to queue up low priority messages rather than attempt #
# delivery immediately if the five-minute load average is greater #
# than some integer value, by default 8. This value is defined on #
# the line beginning O QueueLA=. #
# #
# Refuse-Connections Load Average (option RefuseLA): #
# #
# In order to limit load on a very busy system, the sendmail daemon #
# can be configured not to accept SMTP connections if the five- #
# minute load average is greater than some integer value, by #
# default 12. This value is defined on the line beginning #
# O RefuseLA=.

NOTE: The load average is set as seen in top.

Regards,
I work for HP
David Crowe
Advisor

Re: Limit number of Messages

Thanks for the replies but I have some further questions. If I limit sendmail to a single thread, how does that reduce load? Does it just reduce the amount of mail going to the internal SMTP gateway at one time?

Secondly, (and I could be wrong here) it sounds like Juan's answer is limiting mail being sent to sendmail.

I am looking at limiting at mail being sent from sendmail. The Sendmail server is a relay server which relays mail from the internet to a couple of internal SMTP gateways. The problem that I have is when Sendmail opens a connection with the internal gateway it delivers all of the email that it has which causes the internal server to choke. I want to balance this load across a number of internal gateways. The only way that I can think of is to limit the number of messages being passed to the internal gateway before it breaks the connection and creates a new one with a different gateway.
Kasper Haitsma
Trusted Contributor

Re: Limit number of Messages

Hi,

What you might be looking for is the following parameter in sendmail.cf:

# how many jobs can you process in the queue?
#O MaxQueueRunSize=10000

as well as the folowing two, but I'm not sure if these would be helpfull.

# maximum number of children we allow at one time
#O MaxDaemonChildren=12

# deliver each queued job in a separate process?
#O ForkEachJob=False

HTH
Kasper
HP sendmail OpenMail support engineer
It depends
Stefan Farrelly
Honored Contributor

Re: Limit number of Messages

If you limit sendmail to one thread this means only one process handles mail. Normal practics is if there are say 100's of emails in the queue and you start sendmail it will fork off tens and tens of processes to deliver all mail going to different destinations at the same time. This sudden increase in the number of running processes puts a load on your server, so reducing sendmail to a single thread (process) doesnt put a load on your server.

As you can see there are 3 ways to do this as per others replies;
1. single thread sendmail
2. sendmail keyed to server load (as per uptime command) If server is quiet then it can run lots of processes, if busy then not.
3. limit sendmail to X children - ie. X processes only.

To not impact mail delivery too much I would try option 3. first and adjust the number of child processes until you find a balance. Using option 1. may reduce your mail throughput considerably.
Im from Palmerston North, New Zealand, but somehow ended up in London...
David Crowe
Advisor

Re: Limit number of Messages

Kasper,

If I activate the following, does that mean that each queue job will try to resolve the address for each job?

# deliver each queued job in a separate process?
#0 ForkEachJob=False
Kasper Haitsma
Trusted Contributor
Solution

Re: Limit number of Messages

Hi David,

The answer to your last question, took a little while, but here it is:

When you set ForkEachJob, each message in the queue will have a process to deliver the message. Each forked job will do a resolver call to get the IP/Hostname to canonicalize..

This paramater is really only needed in a memory starved system. It will not provide any load balancing.


Sendmail will randomize MX records of equal value. You can verify this by doing a 17.1 (host signature). Load balancing should occur automatically when the mx records are of equal priority.

I hope this clarifies this.

Kasper
It depends
Christopher Caldwell
Honored Contributor

Re: Limit number of Messages

Generally, I'd limit this on the client side (using a conservative setting for RefuseLA). If the relay's connection gets dropped, it'll know it's got other MXs to try and should balance reasonably.