Relation between max_servers and ncpu

Mark Martinec Mark.Martinec+amavis at
Fri Feb 24 14:19:55 CET 2012


> > I run a server with postfix + amavisd-new + clamav + spamassassin, this
> > server have 8 cores and 16Gb of RAM. We have max_servers=6 set on
> > amavisd.conf and it works as expected, but, when a good number of emails
> > come at the same time, it takes a long time to process the entire queue.
> >
> > I did a simple math average, email are taking about 3s to be processed.
> > 
> > I'm considering increase max_servers on this environment, but i'm worried
> > about if I set it to a number bigger than the number of current CPUs
> > won't be a problem for the other services running in this machine.
> > 
> > Do you have any consideration about that subject? How is the best way to
> > define max_servers value?

Henrik K wrote:
> Look, I have max_servers=20 on an ancient 4x1Ghz SPARC with no problems.
> One amavisd process cannot take 100% cpu for all the 3 seconds. Most of
> that time is waiting for DNS lookups.
> Just put something like 20-30 depending on how you want to prioritize other
> services and mail flow.
> If you put too many, the worst case scenario is that some processes get
> marginally slower (but total throughput will be great).  You need to
> experiment.

I agree with Henrik. For a reasonably modern hardware with sufficient memory
and a sizable mail traffic the max_servers=6 is too low.  The 20-30 is about
right, and even 50 may be acceptable if need be.

There are plenty of latencies during processing of a mail message, especially
if spam scanning is enabled. These idle times can be put to good use when
running multiple child processes.

Keep an eye on the RSS usage (real memory) used by amavisd processes,
these should not come too close to available RAM size. Also see CPU idle
time: when CPU usage approaches 90 or 100% on the average, adding
more child processes brings no advantage, just wastes memory.

In other words: if mail processing is falling behind the traffic rate
and CPU utilization is not close to max and memory permits, increase
the $max_servers and a corresponding MTA stting.

If amavisd-nanny shows that amavisd processes are frequently idling,
or if CPU usage is close to 100% for long periods, or if memory is
tight, decrease $max_servers setting.


More information about the amavis-users mailing list