Reducing Memory Consumption in Elastix 2



  • If you are running an Elastix 2 install, often you do so on very small systems and need to trim memory usage. I used to have a guide to this on my personal tech site which I've since taken down so am replicating the info here as best as I can...

    The biggest thing to modify is HTTPD settings as these tend to use the most memory over time. Some changes that I make include:

    <IfModule prefork.c>
    StartServers       2
    MinSpareServers    2
    MaxSpareServers    6 
    ServerLimit      128
    MaxClients       128
    MaxRequestsPerChild  4000
    </IfModule>
    
    <IfModule worker.c>
    StartServers         2
    MaxClients         120
    MinSpareThreads     20
    MaxSpareThreads     65 
    ThreadsPerChild     25
     MaxRequestsPerChild  0
    </IfModule>
    

    Daemons that are often enabled but should probably be disabled:

    • cyrus-imapd
    • hylafax (if not in use, of course)
    • iscsi
    • iscsid
    • kudzu
    • lvm2-monitor
    • mailman
    • netfs
    • openfire
    • postfix (only if you do not send emails from the system)
    • psacct
    • vsftpd


  • I used to have that article bookmarked. Apparently it is time to edit the location for the bookmark.



  • @NetworkNerd said:

    I used to have that article bookmarked. Apparently it is time to edit the location for the bookmark.

    Me too and now... it's gone.



  • Can you tell if I missed anything?



  • @scottalanmiller said:

    Can you tell if I missed anything?

    I found the help desk ticket I created where I applied the steps in your article, but all I did was leave the link to the article and say I made the changes. Shame on me for not documenting the specifics. I feel like there is more to it but cannot tell you what it is. Maybe @FiyaFly remembers.



  • Long ago I had an article on this on my own blog but that is no longer up, so I am copying it here...

    https://web.archive.org/web/20150221062029/http://www.scottalanmiller.com/linux/2012/09/02/improving-elastix-memory-usage/


    The default installation of Elastix has more services running than are typically needed or desired on a PBX. These services eat far more memory that is necessary and can very easily be cleaned up to improve memory utilization.

    First we will stop a series of unnecessary services from starting at boot time (this will disable shared storage, local email handling, new hardware detection, etc. so be aware that this does stop some things but any service that proves to be needed is trivial to re-enable.)

    chkconfig nfslock off
    chkconfig cyrus-imapd off
    chkconfig iscsi off
    chkconfig iscsid off
    chkconfig netfs off
    chkconfig kudzu off
    

    Further, if your system is like mine you likely use the web server very lightly but will find that the default configuration of Apache is set to spawn, by default, eight processes. This is far too many for a normal deployment. Each process uses memory. For an average deployment of Elastix, three is more than enough. You need only raise this number if web performance suffers. This will not impact telephony performance regardless.

    In the file /etc/httpd/conf/httpd.conf we need to edit the section:

    <IfModule prefork.c>
    StartServers       2
    MinSpareServers    2
    MaxSpareServers   8
    ServerLimit      256
    MaxClients       256
    MaxRequestsPerChild  4000
    </IfModule>
    

    to something more like this:

    <IfModule prefork.c>
    StartServers       3
    MinSpareServers    2
    MaxSpareServers   10
    ServerLimit      256
    MaxClients       256
    MaxRequestsPerChild  4000
    </IfModule>
    

    You can wait for the system to reboot or restart Apache manually:

    service httpd restart
    

    And finally, to control swapping activity on the box, assuming that you want to avoid swapping when unnecessary, which I do because my box is virtualized, simply add this line on to /etc/sysctl.conf:

    vm.swappiness = 10
    

    You’ll want to test that number carefully. A setting of “10” is quite standard for virtualized systems. The default is “60”. For a physical deployment the higher value is likely better as it allows CentOS to make better decisions about how to utilize memory for maximum throughput. But on a virtualized system we really want to avoid, typically, any additional contention at the storage IO layer.
    [Testing on Elastix 2.0 and 2.3]