Becaus of this
thread telling about the huge memory usage of an ISPCP installation (which is about 640 Megabytes) on a virtual private server (VPS) I was searching for some optimization possibilities. Virtuozzo or OpenVZ (which is basically the same but less expensive
based virtual servers don't use a real swap file they only provide, besides the warranted RAM, a burstable RAM (which is swapped on the hardware node so try not to exceed your warranted RAM). If an application exceeds the burstable RAM value it simply won't start.
1. Configure apache worker MPM for low memory usage
On most Systems Apache consumes most memory (in the basic configuration on my System about 480 MB RAM).
So we have to change the MPM workers to a lower value:
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
StartServers 1
MaxClients 100
MinSpareThreads 1
MaxSpareThreads 50
ThreadsPerChild 10
MaxRequestsPerChild 5000
</IfModule>
That suggestion was partly taken from
http://wiki.vpslink.com/index.php?title=...igurations I don't know if its a usefull configuration, hope somebody is willing to test iit, too.
Another value I found important is the default thread stack size (which is 8 Megabytes). I really don't know how much of it is really used by an apache Thread.
Here somebody tells about 1 Megabyte but I think its a bit too less. Actually I use this one (just add it at the end of you /etc/apache2/apache2.conf):
ThreadStackSize 4000000
After every change you have to call
$ /etc/init.d/apache2 force-reload
2. Configure MySQL
Again taken from this
Wiki a my.cnf configuration to make MySQL less RAM intensive.
I used some of the values and changed this parts in the /etc/mysql/my.cnf file:
#
# * Fine Tuning
#
key_buffer = 1M
max_allowed_packet = 8M
thread_stack = 64K
thread_cache_size = 8
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 8M
3. Stop unnessesary memory intensive services
Bind is mostly never used and consumes (about 40 MBs of memory:
/etc/init.d/bind9 stop
TODO: Don't start bind on startup HowTO (just delete /etc/init.d/bind9?)
Stop the greylisting (about 20MB)
/etc/init.d/postgrey stop
According to this FAQ entry:
http://www.isp-control.net/component/opt...iew/id,15/
You just have to uncomment this configuration line. But won't the /etc/init.d/postgrey still be started (TODO)?
All that stuff together has, on my Test VPS, decreased memory usage from about 640 MB to about 200 Megabytes.
Please try it and tell me if you've gotten any problems or think some of this configuration is useless or stupid!