Minimalist memory usuage for asterisk vps

I went about setting up a optimized vps for memory that needed to fit into a 256 meg vm. The setup I have is very minimal in it’s self, 2 extensions + call recording.

Feel free to make suggestions, there seams to be some bash scripts in memory that are loaded with asterisk that don’t seam to be critical that could be optimized if needed.

I started with asterisk 2.02 and this is likely to work on asterisk 3.0 as well.

The end result is 124 megabytes of memory used after startup, with http / mysql still enabled. It is possible to trim the memory foot print smaller but that is not needed in this case.

Here is what I did, the services removed would require you to configure them so removing them or disabling them should have no effect. Switching sshd to xinetd is likely not needed as memory foot print was all ready bellow the required 256 megs

find processes with most ram

ps xau | sort -k5 | less

see total ram used

free -m

remove audit

rpm -e audit amtu autofs

use google

rpm -e redhat-lsb man man-pages-overrides

no blue tooth on vps

rpm -e bluez-utils

acpid for power the power button

rpm -e acpid

x11 won’t be started again

rpm -e xorg-x11-xfs chkfontpath

nfs not needed

rpm -e nfs-utils nfs-utils-lib

no mouse needed in a vps

rpm -e gpm vim-enhanced
rpm -e coolkey pcsc-lite ccid ifd-egate
rpm -e avahi

assuming you are in a vps you don’t need to monitor diskhealth

rpm -e smartmontools

#strip symbols from files

strip /usr/bin/*
strip /usr/sbin/*
echo drop database test | mysql

do yum updates manually

service yum-updatesd stop
chkconfig --levels 2345 yum-updatesd off
chkconfig --del yum-updatesd

most people are not going to have a iscsi configuration

service iscsid stop
chkconfig --levels 2345 iscsid off
chkconfig --del iscsid

service iscsi stop
chkconfig --levels 2345 iscsi off
chkconfig --del iscsi

hal used for power management, has dependancies so just shutting down

service haldaemon stop
chkconfig --levels 2345 haldaemon off
chkconfig --del haldaemon

service acpid stop
chkconfig --levels 2345 iscsid off
chkconfig --del iscsid


network - set your ip to a static ip so that dhclient does not use

2k of memory

#remove mingetty all expect the first one
1:2345:respawn:/sbin/mingetty tty1


This cuts mysql usage all most in half as it does not use innodb

add to /etc/init.d/mysqld
–skip-innodb --default-storage-engine=myisam
and if mysql is upgraded

–default_tmp_storage_engine=myisam \

add to my.cnf


apache /etc/httpd/conf/httpd.conf
This will reduce some of your apache memory foot print but
this is intended if you are having very few hits to your freepbx
admin page

StartServers 1 MinSpareServers 1 MaxSpareServers 5 ServerLimit 50 MaxClients 50 MaxRequestsPerChild 4000

disabled these modules
#LoadModule auth_digest_module modules/
#LoadModule authn_file_module modules/
#LoadModule authn_alias_module modules/
#LoadModule authn_anon_module modules/
#LoadModule authn_dbm_module modules/
#LoadModule authn_default_module modules/
#LoadModule authz_user_module modules/
#LoadModule authz_owner_module modules/
#LoadModule authz_groupfile_module modules/
#LoadModule authz_dbm_module modules/
#LoadModule authz_default_module modules/
#LoadModule ldap_module modules/
#LoadModule authnz_ldap_module modules/
#LoadModule include_module modules/
#LoadModule logio_module modules/
#LoadModule env_module modules/
#LoadModule ext_filter_module modules/
#LoadModule expires_module modules/
#LoadModule usertrack_module modules/
#LoadModule dav_module modules/
#LoadModule status_module modules/
#LoadModule dav_fs_module modules/
#LoadModule userdir_module modules/
#LoadModule proxy_module modules/
#LoadModule proxy_balancer_module modules/
#LoadModule proxy_ftp_module modules/
#LoadModule proxy_http_module modules/
#LoadModule proxy_connect_module modules/
#LoadModule file_cache_module modules/
#LoadModule mem_cache_module modules/
#LoadModule version_module modules/
#LoadModule cern_meta_module modules/
#LoadModule asis_module modules/

risky, you could could your self knocked off the vps for this

I started a second sshd as a backup

/usr/sbin/sshd -p 2222

Then create
— contents —
service ssh
socket_type = stream
protocol = tcp
wait = no
port = 22
user = root
server = /usr/sbin/sshd
server_args = -i
disable = no

restart xientd and check for config errors in /var/log

#/etc/init.d/xinetd restart

disable sshd

service sshd stop
chkconfig --levels 2345 sshd off
chkconfig --del sshd

that seams to kill the backup sshd as well, start it

/usr/sbin/sshd -p 2222

login on backup ssh with ssh user@host -p 2222

logout of current sshd

#on backup sshd kill old sshd
kill fuser 22/tcp

restart xinet

/etc/init.d/xinetd restart

#sshd should be there an port 22 again
#telnet localhost 22

kill old server

kill fuser 2222/tcp

#now sshd will only take up ram when you are logged in by ssh

if you have access to console you will see no sshd, so 10000

less memory used

ps xau | grep ssh

more reductions ?

sendmail could be configured for xinetd as well

could reduce it more here