Improve LAMP performance, for low cost servers or VPS

As I said last day I’m just in a migration, I just did 2 sites a really not relevant one and deambulando.com, with lot of visitors. The server I’m using should be enough to handle the amount of visitors, but just in case I do a bit of tuning to improve the overall performance of the machine.
This config is meant for VPS servers like (or kind of):
- Celeron 1.2Ghz
- 512Mb Ram
- 10Gb HD
- 100Mbps upload/download
- Linux
Depends in witch linux version you are running the LAMP the files can be in different paths, to find them you can always use : locate my.cnf
Apache (apache2.conf):
StartServers 2
MinSpareServers 5
MaxSpareServers 10
MaxClients 30
MaxRequestsPerChild 100
Php (php.ini):
max_execution_time 30
max_input_time 60
memory_limit 32M
output_buffering 4096
Mysql (my.cnf):
key_buffer_size = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
set-variable=max_connections=200
set-variable=wait_timeout=15
max_connect_errors = 100
UPDATE: to help with the Mysql config I’ve found this awesome script
All this config parameters are the most relevant to improve anything. In my config all the parts where is memory I have double it, since I have 2Gb of memory, the rest remains almost the same.
Maybe you will not see a great speed improvement but if you have enough traffic you will see lot less stress in the server side.
I’m almost sure that “MaxClients 150″ will kill that server, 512MB is too little. I would lower MaxClients to 30 or 40 (every apache proc may consume by default 10MB of RAM, or more, 10*30 = 300MB of RAM) and KeepAliveTimeout to 5, to free every child as soon as possible. You have to avoid the use of swap. If your system starts to use swap, your server is dead.
I would lower a little the MySQL parameters too.
For PHP, APC is a good way to improve performance.
Hello!
You are damn right, the max clients is wrong. Is better how you say. I just check documentation and you are right. About KeepAliveTimeout I think is a good idea too.
APC I’ve never tried but I think I should at least bring it a chance.
Thanks and regards ;)
i suggest you to use lighttpd for a low cost server it is better then apache
try it
I think I will because this works soooooooooooo slow still with the dedicated server :(