http://www.perlmonks.org?node_id=161077


in reply to Net::SMTP slow on linux

I've done a lot of work with Net::SMTP on several platform and have found the performance to be comporable on roughly equivalent hardware regardless of OS. Perhaps if you gave us some details on your setup we could help: are you using persistant SMTP connection, how is postfix configured, is postfix running on thesame server with your perl script (i.e. was postfix also moved from Solaris to Linux), what hardware were you using for the Solaris and Linux setups, etc...

Replies are listed 'Best First'.
Re: Re: Net::SMTP slow on linux
by shadowpuppet (Acolyte) on Apr 22, 2002 at 18:35 UTC
    Thanks. It's a persistant connection to localhost (actually I restart every 1000 emails). The linux server is a dual p3 1.1Ghz with 4G ram. We have two solaris, one quad 450 4G, and a dual 450 with 2G ram. The Net::SMTP performance is similar on the both. I think I may have figured out the difference in performance, the solaris server(s) are on an EMC array, while the linux is off localdisk. The performance is pretty good on linux if I send a single mail to tons of recipients, but not one mail per recipient. I need to be able to send in both ways. I guess the localdisk may explain that.
    --Jim
      You are correct. Postfix (and MTAs in general) are extremely disk IO intensive. If you're looking into improving performance of the system, I recomend you look into a faster disk subsystem. A lot of work can be done tweaking Postfix for optimal performance too (running a second instance for defered emails, tuning the # of processes and SMTP timeouts, moving spools onto their own disks (or at least separate partitions), if you're willing to risk loosing data in the event of a power outage you can also try using a ramdisk for spool, etc...)

      You may be able to squeeze a little more performance out of your existing system by generating (and delivery to postfix) mails in parallel. I was running on a e450 for a while with 4 CPUs and postfix and I found that my optimal generation rate was produced by having 8 simultaneoue mail generation/injection processes. Your performance may vary, but its worth looking into. If you try this, be careful not to flood postfix's mailqueues. If they grow too large performance will suffer.

        Yes, the generating in parallel was something we discovered as well. Although the max injection rate (SMTP submits) we could get out of a process was 250,000 per hour, we discovered that doing 2 at a time didn't slow down this rate much. We were thinking of running 4 at a time on each server. But I'll trust and suggest your number 8 - that makes sense. If I can linux to submit at 250,000 by putting it on EMC array (which is like ram disk), we'll be in business with multiple processes. On a side note, the 250,000 was up from 125,000 when I made the following code change on Net::Cmd ->
        line 476__ $main::ignore_response ? 1 : ($cmd->response == CMD_OK);

        I noticed alot of delay in waiting for the response when a mail was finished submitting to postfix. I set ignore_response as a global in the sending program.

        Thanks for your help and confirmation of the multiple-processes strategy.
        --Jim