If you're paying a good sum of cash for your server - VPS, dedicated, cloud, whatever - you want to get the most for your money.
Particularly if you're running an Apache server and you've never changed its configuration, the chances are it's not running anywhere near its maximum potential. In the past, I've been able to avoid several thousand dollars' worth of upgrades to key servers just by spending an hour tweaking some of the numbers in Apache's basic configuration settings.
Here's a quick tutorial on how to optimise your settings - particularly if you're finding that your server is becoming slow or even crashing, this stuff could save you upgrade fees or the cost of lost conversions. It's a bit of a pain, but it's not hard to do!
You'll need to have SSH access to your server's command line for this tutorial, and you'll also need to know the basics of Linux command line usage. Don't worry - you don't need super-sysadmin knowledge. If you can edit text files and change directories, you'll be fine.
How much performance can you get out of this?
For reference, I've been tuning a new Apache VPS using the approach in this tutorial whilst I was writing it.
After tuning, my 1Gb VPS running prefork Apache was able to handle 250 simultaneous clients, no timeouts and 7,200 hits in a minute without slowing below 40ms per request. That's on a live landing page.

I also tested it with 500 simultaneous users - that's the equivalent of about 180,000 clicks a day - and whilst the loading time spiked to a maximum of 400ms, the server handled the load fine.
Apache wouldn't be my first choice of web server software, but if you're using it, you can still get a lot of performance - and money - out of it.
Step One: Determine The Size Of Apache's Ass
Apache has a big butt. I can't lie. It does indeed look fat in that. In short, it eats memory like it's extra-heavy chocolate cake.
One of the most common ways that Apache will slow down is if it runs out of memory on the server. In that case, it'll still make new copies of itself in memory, but it'll start using hard disk space as "spare" memory, slowing it down by 20x or more.
To avoid that, we need to figure out how much memory we have available, and how much memory Apache needs.
SSH into your web server - whilst it's running Apache, Mysql, and everything else you use - and run
ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'
free -m


aptitude search apache2-mpm-


I'm definitely confused.. but i'll go through this thread 10 times until i'll get this sorted. the "small" things which makes you more money need to get full attention.
Is it relevant to litespeed servers..?
Good stuff, caurmen!
Thanks!
This one's Apache only. Litespeed has a more complex performance architecture and also ships with more sensible defaults, so this tutorial's aimed at the low-hanging performance fruit of Apache servers.
However, elements of this tutorial - checking the memory usage of your web server and using Top - can apply to other web servers too.
What parts confused you? I'm more than happy to clarify and explain further.
Thank you Dr Sheldon Cooper!
Tying to optimize my server. When I execute the following code:
ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'
Apache Memory Usage (MB): 0 awk: (FILENAME=- FNR=1) fatal: division by zero attempted
Thanks that works out great.
Another question is it correct to set MinSpareServers, MaxSpareServers to the same value?
Apache has terrible performance even when max clients are turned up. It can serve static content ok but any thing dynamic (ie php... everything server side scripted) is terrible!
Just the other day I was helping migrate a customer that had a 32 core server with apache maxed out and a load average of 3500!
I installed litespeed 1 cpu and lit it up, load dropped to 2 and everything began loading instantly.
Apache is good for basic web applications and sites, but its not a solution if you want to make money.
@kash50 -Yep, that's probably the best option. They're unlikely to have a huge effect on your performance most of the time.
Just a small question Caurmen, didn't want to create a new thread for it. Are you running APC on your server in combination with memcache?
@panicore - Depends on which server, but usually yes. I haven't done a full benchmark with and without APC, but using some kind of opcode cache is good practise in general.