How do I get SpamAssassin to run faster?
Use [http://www.spamassassin.org/full/3.0.x/dist/spamd/README spamd].
Ensure you are not using a locale that uses UTF-8; UTF-8 character sets have higher overhead for text-processing applications: Utf8Performance
If you are using network tests, install a local DNS server (BIND named, for example) on the same host to cache responses, and set the /etc/resolv.conf file to use that instead of one on another machine.
Consider turning off network tests, and running with "-L", if you can afford a drop in accuracy. (This is not a very good option for most people though.)
Are you experiencing high system load or possibly swapping? Look at the number of children you have spawned, and compare that to the available memory (by default each child can use 20-30 megs of RAM). Depending on load you might find success in lowering the number of children that are spawned (see -m in the spamd documentation).
For heavily loaded servers, you may be experiencing high iowait times depending on how hard you are hitting your disk. You can try offloading the logging and bayes disk writes to a separate disk.
Examine the custom rule set files you use.
- Avoid large rule sets, those over 100k or 150k in size. The more rules you have, the slower SA will run.
- Pick rule set files that are more productive. In the SARE families published by Bob Menschel, use files 0 and 1 for productivity / efficiency, and avoid files 2 and 3.
- Remove and re-add rule set files one at a time, and check performance after each change. If one rule set file causes a huge change in performance, take appropriate action.
Examine the custom rules you create. Regular expressions with lots of flexibility use lots of resources. Avoid body rules that use "+" or "*" attributes.