> > I found two perl examples that are within my skill to understand > > and one is based from the example code in the Postfix > > examples/smtpd-policy/greylist.pl if you don't know I think this is > > http://heap.altlinux.org/usr/share/doc/postfix-2.2.11/examples/smtpd-policy/greylist.pl > > so its run by Postfix's spawn service. Perl code itself no threading, > > no forking just like one-time script because Postfix takes care of > > the rest right? > > It's not a one-time script.
But it is written as such. It's main loop is like this: while (<STDIN>) { ... } So executed outside of Postfix it is a one-time script. > It does not handle one request and > terminate. That would not scale under load. > > There is one Perl script interpreter process per Postfix SMTP daemon > process, and it terminates when the Postfix SMTP daemon process > terminates. Each Postfix SMTP daemon process handles up to 100 > SMTP sessions, so the cost of creating the Perl process is very > much reduced compared to a one-time script that handles one request > and terminates. Thats what I mean "Postfix takes care of the rest" (for anyone who likes to digress, I am interested to learn how Postfix takes simple one-time script and keeps it alive for multiple uses.) > > Other example, it runs as daemon itself, so Postfix not in charge, > > only makes call to it from smtpd_*_restrictions. See its here: > > https://github.com/bejelith/send_rate_policyd > > > > I can put 2nd one under systemd so it can be monitored and restart > > if it goes down. > > > > Question is if there is any major difference in these implementation? > > In high volume situation is one better than other? > > > That depends on how the non-spawn(8) implementation is done. I sent the link in my first message. i think important points are like: # fork into daemon # creates some threads each listen for connections # monitors threads every 5 seconds # if ratio of running/waiting threads is more than .9 create one new thread Other code review of that person's code from experts will be interesting but main question is still to use Postfix spawn or run own daemon? Thanks you.