Over the last few months, I’ve been monitoring Apache’s usage of memory and CPU for 10 virtual hosts on one of my VPS. I found that Apache regularly ate up 480MB of RAM after a couple days running, as this is getting dangerously close to my VPS limit, I had a play and optimised it a little.
I got the load down to 380MB, but that’s still not good enough.
With the optimisation that I’d done to reduce memory load, I was starting to find that static assets are taking a while to load, typically all of the items on a standard e-commerce product listing page was taking around 3s to display. This was giving a negative user experience, so today I set about seeing what I could do to speed up the static assets, and keep a low memory footprint.
I’d heard people talking about running Lighttpd and Apache together, using Lighttpd to serve static assets – this seemed like a good idea, so I went ahead and configured Apache to listen on 127.0.0.1 only, and on a port that wasn’t 80.
This meant that I could have Lighttpd running on port 80, and filtering what traffic went to Apache.
Already I was down to 0.5s page-load speed, and down to 300MB memory footprint. Good, but could I do better?
Nginx came to the rescue, very simple set up for all of my virtual hosts, which fed directly into Apache for all server-side scripts, with nginx serving static assets. Down to a 0.2s page load, 280MB RAM usage and barely any CPU load regardless of the amount the server gets hit.










