Improving Elastix 2 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]
Originally posted on my Linux blog in 2012 here: http://web.archive.org/web/20140822224153/http://www.scottalanmiller.com/linux/2012/09/02/improving-elastix-memory-usage/