[Pymilter] Number of threads

Stuart D. Gathman stuart at bmsi.com
Mon Dec 27 11:37:45 EST 2004


On Mon, 27 Dec 2004, Roman Suzi wrote:

> > Sendmail already throttles the connect rate, and as long as the average
> > elapsed time of a milter thread stays under what sendmail expects, then
> > there is no problem.

> > I would focus on discovering what is making the milter threads take so long.

> Mail comes in bursts. Sometimes milter is dead in 3 minutes, because
> 30 * 60 * 3 = 5400 - which is > 1020 five times.
> (connection throttle in sendmail = 30)

Sendmail limits the number of sendmail processes receiving mail.  There can be
only one milter thread per sendmail process - unless something goes wrong.
That something is a milter timeout.

In sendmail.mc, you should have a line looking something like this:

INPUT_MAIL_FILTER(`pythonfilter', `S=local:/var/run/milter/pythonsock, F=T, T=C:5m;S:30s;R:5m;E:5m')

The R timeout is 5 minutes.  That means, if a milter thread takes longer than
5 minutes to send a response to sendmail, sendmail will give up, return a 451
to sending MTA, and start a new connection.  This creates yet another python
thread, making it yet more likely that sendmail will give up on a python
thread.  This is how python ends up having more milter threads than sendmail
processes.  A similar problem can result from the other timeouts.

One solution is to implement the progess method (define _FFR_SMFI_PROGRESS
when compiling sendmail and miltermodule.c).  This call lets you keep
sendmail waiting as long as you like.

Another solution is to increase the timeout in the milter definition to
match your application.

A third solution is to fix the application so it doesn't take so long.

I would check the sendmail log for milter timeout errors - this should
let you know which timeout sendmail is hitting, and either increase it
or adjust your application.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Pymilter mailing list