My linode story:
i used to host on a linode 200 several domains with all the standard stuff a company needs: mail [postfix], pop3 [dovecot], web [apache+php], MySQL, ftp [vsftpd]. CPU usage minimum. The websites had reasonable traffic. peak times: 2-3 requests / pres second, for small periods of time.
The problem was RAM. it a few hours after restart it went swapping 120 MB and stayed there.
I said, wow, what's the problem. Reading these forums, i saw LAMP guys handling all I had, in a Linode 100 with little swap. [one was cruel enough to post free -m output and had 3 MB swapping].
I started optimizing.
After studying my system, i concluded that MySQL and Apache+mod_php5 ws the problem.
MySQL: [/etc/my.cnf]
skip-innodb -- it saves some RAM
skip-bdb
skip-networking -- they say it is good if you don't really need it, i didn't
query_cache_type=1 -- these 3 lines make your website run faster
query_cache_limit=1M
query_cache_size=32M
for the Apache and php i adopted the following architecture:
LightTPD in front of a spartan-compiled apache with a spartan-compiled php.
LightTPD would serve all the static files, and the rest was proxied to the apache that was listening on 8080 only on 127.0.0.1.
the transition was not easy. i had it all: vhosts, rewrites, ssl domain, auth basic.
but i did it.
apache:
--prefix=/usr/local/apachephp --exec-prefix=/usr/local/apachephp --disable-v4-mapped --disable-authn-file --disable-authn-default --disable-authz-host --disable-authz-groupfile --disable-authz-user --disable-authz-default --disable-charset-lite --disable-include --disable-env --disable-setenvif --disable-status --disable-autoindex --disable-asis --disable-cgi --disable-imap --disable-actions --disable-userdir --enable-so --disable-echo --disable-dbd --disable-isapi --disable-example --disable-filter --disable-ldap --disable-log-config --disable-env --disable-proxy --disable-proxy-ftp --disable-proxy-ajp --disable-proxy-balancer --disable-dav --disable-status --disable-cgid --disable-cgi --with-mpm=worker --disable-alias
now i have:
httpd -l
core.c
mod_auth_basic.c
worker.c
http_core.c
mod_mime.c
mod_negotiation.c
mod_dir.c
mod_so.c
php:
./configure --with-apxs2=/usr/local/apachephp/bin/apxs --disable-cli --disable-dba --without-mod_charset --disable-cgi --disable-debug --enable-safe-mode --enable-magic-quotes --disable-rpath --disable-ipv6 --disable-all --enable-bcmath --with-curl --enable-ftp --enable-gd-native-ttf --with-gd --with-mysql=/usr/local/include/mysql --with-mysql-sock=/tmp/mysql.sock --enable-sockets --without-pear --with-pcre-regex --enable-session --with-zlib-dir=/usr/include --enable-exif --with-jpeg-dir=/usr/local/ --enable-inline-optimization
[yes, i needed a lot of stuff]
in httpd.conf i put keepaliverequests to off, as apache will execute the php, send the result to lighttpd on local sockets [fast], and then it frees the resource . In the old configuration a 11MB apache process would of been reused for for sending to the browser 100 bytes blank.png files too.
Now i can do the work of the old 5 mpm apache workers with only 2.
now LightTPD, it is just great. i haven't tuned as it is so very tuned by default. i just migrated the rules and vhosts and rewrites to it, and proxied php scripts to apache.
now here is my free -m output after 1 day of hard work from my slack linode:
free -m
total used free shared buffers cached
Mem: 191 157 33 0 11 85
-/+ buffers/cache: 61 130
Swap: 256 0 256
basically the changes that saved me were: lighttpd, the apache/php tunning and the cache in the mysql. the rest , sure helped, but not so much in my opinion.
if you guys have any other tips and tricks about squeezing performance out of our linodes, I welcome any other sugesstions.
This is what I am going to do this summer vacation, so i can have the best linode around

.