Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a VPS on 1and1 similar to this configuration (512MB, burst up to 2GB). I run a web service where I crawl the web and notify my users through email and sms when a certain online data feed changes.

When I send the emails out, I just have PHP loop through the recipients list and send the emails out using the mail() function. Whenever I try to send a large volume of these messages out, my server starts acting funny. I can't even run an 'ls' sometimes because the shell tells me it 'cannot allocate memory'. The shell is unusable and yet my website is being served up fine.

Mail.err contains:

Nov 14 17:30:09 s15351477 postfix/smtp[26000]: fatal: inet_addr_local[getifaddrs]: getifaddrs: Cannot allocate memory
Nov 14 17:30:09 s15351477 postfix/sendmail[25999]: fatal: username(1000): unable to execute /usr/sbin/postdrop -r: Success
Nov 14 18:29:14 s15351477 postfix/smtp[9911]: fatal: inet_addr_local[getifaddrs]: getifaddrs: Cannot allocate memory
Nov 14 18:29:14 s15351477 postfix/sendmail[9910]: fatal: username(1000): unable to execute /usr/sbin/postdrop -r: Success

Also, if relevant, my bean counters are:

Version: 2.5
       uid  resource                     held              maxheld              barrier                limit              failcnt
 53907331:  kmemsize                 20779422             21041560             31457280             34603008              2989403
            lockedpages                     0                    0                  512                  512                    0
            privvmpages                 81488                82498               524288               576716                94640
            shmpages                     2831                 2831                32768                32768                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            numproc                        90                   91                  128                  128                 6603
            physpages                   32692                33531           2147483647           2147483647                    0
            vmguarpages                     0                    0               131072           2147483647                    0
            oomguarpages                32942                33781  9223372036854775807           2147483647                    0
            numtcpsock                     22                   23                  720                  720                    0
            numflock                       27                   28                  376                  413                    0
            numpty                          1                    1                   32                   32                    0
            numsiginfo                      0                    1                  512                  512                    0
            tcpsndbuf                  425888               441064              3440640              5406720                    0
            tcprcvbuf                  369200               376832              3440640              5406720                    0
            othersockbuf               268000               268464              2252160              4194304                    0
            dgramrcvbuf                     0                 8472               524288               576716                    0
            numothersock                  180                  182                  720                  720                    0
            dcachesize                 952146               966231              5242880              5767168                    0
            numfile                      3609                 3683                 8192                 8192                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            numiptent                      25                   25                  200                  205                    0

Is there some way I can throttle postfix to keep it from swamping the system like this? Also wondering: why does email use so many resources, these emails are just short text?

share|improve this question
3  
Why are you on an OpenVZ-based VPS? –  Michael Hampton Nov 15 '12 at 3:48
    
Agreed with Michael. Get a real VPS. OpenVZ is horrible. –  EEAA Nov 15 '12 at 4:00
    
I am not sure what OpenVZ is, but I migrated my server to linode.com tonight. Hoping it will perform better now. –  teddybeard Nov 16 '12 at 9:59

2 Answers 2

up vote 2 down vote accepted

Postfix is not using your memory; even on a loaded system (>100k daily) it consumes only about 100MB RSS, with email being continually piped to external processes.

The meory hog is invariably PHP; unless you're using modern ways to serve it, it will consume all of your memory, fast.

Most PHP code leaks something fierce, too.

share|improve this answer
    
This. I'd suggest posting your code over at stackoverflow and asking how to conserve memory. –  Sammitch Nov 19 '12 at 17:50

Reduce the default number of maximal concurrent processes for each service in main.cf:

default_process_limit = 10
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.