The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed spamassassin memory hog

Discussion in 'General Discussion' started by bsasninja, Aug 2, 2007.

  1. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    Well, after breaking my head in a change to make spamassassin to use less resources. Well the main problem is that spamassassin by default in the cpanel config is scanning everything. From 1k messages to the infinite.

    So if you receive huge amount of emails (including emails with large size) spamassassin will scan them anyways taking unnecesary resources.

    Nowadays we dont see spam messages of 1mb of size (luckly :p) their are small and they are not above 100k.
    In my case I limited spamassassin message scan size to less or equal to 80K.
    Messages above 80K, will not be scanned at all. Earning unnecesary cpu load.
    No spamd process are not more than 28-30m of RES size.

    Cpanel development team should take care of this in a next update, adding to the exim configurator editor an option where you can set the size limit for message scanning.
    Also you can reduce spamd the childs from 5 to 3 for more performance (editing /etc/init.d/exim.conf)
    Question: which is the impact of having spamd childs set to 1 ?

    This is how my exim.conf file looks after the modification, red line is what I added:
    Running exim 4.66 with spamassassin 3.2.2.

    warn
    condition = ${if <={$message_size}{80K}}
    condition = ${if eq {${acl_m0}}{1}{1}{0}}
    spam = ${acl_m1}/defer_ok
    log_message = "SpamAssassin as ${acl_m1} detected message as spam"
    add_header = X-Spam-Subject: ***SPAM*** $h_subject
    add_header = X-Spam-Status: Yes, score=$spam_score
    add_header = X-Spam-Score: $spam_score_int
    add_header = X-Spam-Bar: $spam_bar
    add_header = X-Spam-Report: $spam_report
    add_header = X-Spam-Flag: YES
    set acl_m2 = 1

    warn
    condition = ${if <={$message_size}{80K}}
    condition = ${if eq {${acl_m0}}{1}{${if eq {${acl_m2}}{1}{0}{1}}}{0}}
    add_header = X-Spam-Status: No, score=$spam_score
    add_header = X-Spam-Score: $spam_score_int
    add_header = X-Spam-Bar: $spam_bar
    add_header = X-Spam-Flag: NO
    log_message = "SpamAssassin as ${acl_m1} detected message as NOT spam"

    deny
    condition = ${if eq {${acl_m0}}{1}{${if >{$spam_score_int}{100}{1}{0}}}{0}}
    log_message = "The mail server detected your message as spam and has prevented delivery (100)."
    message = "The mail server detected your message as spam and has prevented delivery."

    No I have more free memory, load is more stable than before and spamd childs of 100m> dissapeared.
    Please post here if you have more improvements, tweaks for exim and SA.
     
    #1 bsasninja, Aug 2, 2007
    Last edited: Aug 2, 2007
  2. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,426
    Likes Received:
    2
    Trophy Points:
    38
    cPanel Access Level:
    DataCenter Provider
    If there are a lot of requests to spamd then you'll end up with unscanned mail.

    It looks like previous versions did check the message size @ 200k, but it was removed in later ones. I am investigating this now.

    UPDATE: It seems people were unhappy that the spamassassin headers were missing because it was not scanned so the limit was removed.

    UPDATE #2: I like the idea of offering an editable value here as it should make everyone happy (well hopefully). Since we wrote the exim config manager in whm recently to be much more versatile this should be pretty easy to add. Hopefully we can have it out by the end of the day or late tomorrow depending on how long it takes to QA (should be a very small change though)
     
  3. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    Excelent!! Now I have nice load with exim and SA anyways I have to tweak some settings with apache now :)

    When is not a thing is the other hehe :D
     
    #3 bsasninja, Aug 2, 2007
    Last edited: Aug 2, 2007
  4. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    As I reduced the scan size now memory usage is less. Before 45% used, now 32%.
    Anyways I would like to know at /etc/mail/spamassassin directory the are files like local.cf init.pre and others that have plugins to spamassassin.

    All of them are necessary or the are some of this plugins that take much time to scan as URIBLDNS?

    I would like to know comments of which you have active.

    Thanks!
     
  5. claudio

    claudio Well-Known Member

    Joined:
    Jul 31, 2004
    Messages:
    201
    Likes Received:
    0
    Trophy Points:
    16
    nice thread congratulations

    do not forget to update it when whm exim configurator is ready to do this memory limit to spamd

    by now i will try the manual adjust you kindly suggest

    best regards
    Claudio:)
     
  6. InternetPEI

    InternetPEI Well-Known Member

    Joined:
    May 26, 2003
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    16
    There is an option there now I believe?

    ** Maximum size in kilobytes of a message that will be scanned by SpamAssassinTM.

    WHM 11.2.0
     
  7. Fernis

    Fernis Well-Known Member

    Joined:
    Oct 28, 2006
    Messages:
    192
    Likes Received:
    1
    Trophy Points:
    18
    Yep, the default size is set at 200 kb
     
  8. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    I suggest to set it at 80kb. I didnt see spam over that size yet (luckly) :)
     
  9. majoosh

    majoosh Well-Known Member

    Joined:
    Feb 18, 2006
    Messages:
    97
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    India
Loading...

Share This Page