Reseller Login or Sign up FAQ Search
ResellersPanel's Blog

How to reduce the SpamAssassin load

If you are running a SpamAssassin ‘daemon’ on your VPS or Dedicated Server to look out for spam messages on your site, you should know that it can create multiple (typically 5) threads/processes and each of those threads can use a very large amount of memory, which can slow down the overall server performance or lead to possible Out Of Memory (OOM) errors . SpamAssassin works very well with just one thread. So you can reduce the ‘children’ setting and reclaim some memory on your server for other apps to run with. You can use the following shell script to do so: #!/bin/bash for location in /etc/default/spamassassin /etc/sysconfig/spamassassin; do if [ ! -e $location ]; then continue; fi replace “SPAMDOPTIONS=\”-d -c -m5 -H” “SPAMDOPTIONS=\”-d -c -m1 -H” — /etc/init.d/spamassassin replace “\-m 10 ” “-m 1 ” — $location replace “\-m 5 ” “-m 1 ” — $location replace “\-m5 ” “-m1 ” — $location replace “max-children 5 ” “max-children 1 ” — $location done Don’t forget to make the file executable with the following command: chmod +x /root/memmon.sh Another thing to know about SpamAssassin is that any /etc/procmailrc entry only does one SpamAssassin check at a time. Otherwise, if you receive a batch of incoming emails, they will all be processed in parallel. This could cause your server’s CPU usage to spike, slowing down your other apps, and it may cause your server to run out of memory. To make procmailrc run only one email at a time through SpamAssassin, use a lockfile on your recipe line, e.g. change the top line from: :0fw: # The following line tells Procmail to send messages to SpamAssassin only if they are less than 256000 bytes. Most spam falls well below this size and a larger size could seriously affect the performance.) * < 256000 | /usr/bin/spamc To: :0fw:/etc/mail/spamc.lock # The following line tells Procmail to send messages to SpamAssassin only if they are less than 256000 bytes. Most spam falls well below this size and a larger size could seriously affect the performance.) * < 256000 | /usr/bin/spamc
Originally published Friday, March 19th, 2010 at 12:57 pm, updated March 19, 2010 and is filed under Dedicated Hosting Services.

Tags: ,

Leave a Reply


« Back to menu