Apache vs Lighttpd: Stop Melting Your RAM
Letâs be honest: default Apache configurations are a crime against hardware. I recently inherited a legacy setup for a media client in Osloârunning a standard LAMP stack on CentOS 5âthat was crashing every time traffic spiked above 500 concurrent users. The diagnosis wasn't a DDoS attack; it was MaxClients set too high for the available physical memory, causing the machine to swap itself to death.
In 2011, hardware is getting cheaper, but RAM is still a precious commodity. The debate between Apache HTTPD and Lighttpd (Lighty) isn't just about preference; it's about architecture. Do you want the Swiss Army knife that weighs a ton, or the scalpel that cuts through the C10k problem?
The Heavyweight: Apache 2.2
Apache is the backbone of the internet. It powers over 60% of all websites for a reason: compatibility. If you need .htaccess files for per-directory configuration or rely on a specific module like mod_security, Apache is non-negotiable.
However, Apacheâs traditional Prefork MPM (Multi-Processing Module) is a memory hog. It spawns a separate process for every connection. If you have a PHP process consuming 25MB of RAM and 100 users hit your site, you just lost 2.5GB of RAM. On a standard Virtual Private Server, that's often a death sentence.
Pro Tip: If you are stuck with Apache, switch to the Worker MPM and run PHP via FastCGI. In yourhttpd.conf, lower yourKeepAliveTimeoutto 2 seconds. Don't let idle browsers hold your server processes hostage.
The Challenger: Lighttpd
Lighttpd was born to solve the load problem. Unlike Apache, it uses an asynchronous, event-driven architecture. This means it doesn't spawn a new process for every user. Instead, it uses a single process with an event loop (specifically epoll() on Linux) to manage thousands of connections.
For high-traffic sites serving static contentâimages, CSS, JavaScriptâLighttpd obliterates Apache. I've seen Lighttpd serve 10,000 concurrent connections while consuming less RAM than Apache does serving 200.
Configuration Simplicity
Lighttpdâs configuration is also far more readable than Apacheâs XML-style verbosity. Here is how simple it is to enable compression in lighttpd.conf:
server.modules += ( "mod_compress" )
compress.filetype = ("text/plain", "text/html", "text/javascript", "text/css")
The Trade-off: Compatibility vs. Speed
The move to Lighttpd isn't free. You lose .htaccess support entirely. If your development team relies on overriding configs in every subdirectory, they will hate you. You also have to manage PHP processes separately using php-cgi and a spawner like spawn-fcgi.
| Feature | Apache 2.2 (Prefork) | Lighttpd 1.4 |
|---|---|---|
| Architecture | Process-based (Blocking) | Event-based (Asynchronous) |
| Memory Footprint | High (scales with clients) | Low (constant) |
| Dynamic Content | Native (mod_php) | FastCGI only |
| .htaccess | Supported | Not Supported |
Disk I/O: The Silent Killer
You can tune your web server all day, but if your disk subsystem is slow, your site will crawl. This is especially true here in Norway, where data locality matters. When your database starts thrashing the disk, CPU wait times skyrocket.
This is why we engineer CoolVDS differently. While many hosting providers pack users onto servers with standard 7.2k RPM SATA drives, we are aggressively rolling out enterprise-grade SSD storage and 15k SAS RAID arrays. In a high-concurrency environment, the random read/write speeds of an SSD are the single biggest upgrade you can makeâoften reducing page load times more than switching from Apache to Lighttpd.
Latency and Local Law
If your target audience is in Oslo, Bergen, or Trondheim, hosting in Germany or the US is inefficient. The latency penalty adds up, especially with the chatty nature of HTTP/1.0 and 1.1 protocols. Furthermore, adhering to the Personopplysningsloven (Personal Data Act) is straightforward when your data never leaves Norwegian soil.
CoolVDS infrastructure is peered directly at the NIX (Norwegian Internet Exchange). We keep the packets local, ensuring that your perfectly tuned Lighttpd server isn't bottlenecked by a transatlantic fiber hop.
Final Verdict
If you are hosting a complex CMS with varied plugins and lazy developers, stick to Apache but tune it aggressively. If you need to serve static assets to thousands of users or run a high-performance custom app, Lighttpd is the professional choice.
Whatever you choose, don't let slow hardware undermine your configuration work. Deploy a high-performance Linux VPS with CoolVDS today and see what low-latency SSD storage does for your load times.