The Server Wars: Apache vs. Lighttpd in 2011
It is the nightmare scenario for any sysadmin: It is 3:00 AM, and your Nagios pager goes off. Your site has just been linked on Digg or Slashdot. Traffic is spiking vertically. You SSH in, run top, and see the load average climbing: 10, 25, 40. Your RAM is exhausted, swap is thrashing, and Apache has locked up. The server isn't just slow; it's dead.
If you are running a high-traffic site in Norway, trusting the default configuration of your web server is negligence. The debate currently raging in server rooms from Oslo to Trondheim is clear: Do you stick with the battle-tested compatibility of Apache 2.x, or do you migrate to the asynchronous speed of Lighttpd (Lighty)?
As systems architects at CoolVDS, we see this struggle daily. Clients migrate to our Xen-based VPS platforms because shared hosting crumbled under load, only to find that raw hardware isn't enough—you need the right software architecture.
The Heavyweight: Apache HTTP Server
Apache is the bedrock of the internet. It powers over 60% of all websites. Its greatest strength is its modularity and the ubiquitous .htaccess file, which allows developers to modify server behavior per directory without restarting the daemon.
The Problem: The C10k Barrier
Apache (specifically the Prefork MPM) creates a new process for every connection. If you have 10,000 concurrent users, you need a massive amount of RAM to handle 10,000 threads. On a standard VPS with 512MB or 1GB of RAM, Apache can hit a wall quickly.
Pro Tip: If you must use Apache, stop using the defaulthttpd.conf. Adjust your MaxClients to match your available RAM, not the default 256.
Run:ps -ylC httpd --sort:rssto see how much memory each child uses.
The Challenger: Lighttpd (Lighty)
Lighttpd was designed to solve the "C10k problem" (handling 10,000 concurrent connections). Unlike Apache's process-blocking model, Lighttpd uses an asynchronous event loop. It leverages kernel-level calls like epoll (on Linux) or kqueue (on BSD) to handle thousands of connections with a single process.
Why switch to Lighty?
- Memory Footprint: It sips RAM where Apache gulps it.
- Static Content: For serving images, CSS, and JS, it is drastically faster than Apache.
- CPU Load: Lower context switching means your CPU load stays manageable during spikes.
Real-World Configuration: Lighttpd
Here is a snippet for a high-performance lighttpd.conf tuned for a static media server running on a CoolVDS instance:
server.max-worker = 4
server.max-fds = 2048
server.event-handler = "linux-sysepoll"
server.network-backend = "linux-sendfile"
# Compress content to save bandwidth
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ("text/plain", "text/html", "text/javascript", "text/css")
The Trade-Off: Compatibility vs. Speed
Lighttpd is not a drop-in replacement. It does not support .htaccess files. This breaks many off-the-shelf PHP scripts (like WordPress or Joomla) unless you manually translate the rewrite rules into the lighttpd.conf syntax. For a development team, this adds overhead.
| Feature | Apache 2.2 | Lighttpd 1.4 |
|---|---|---|
| Architecture | Process/Thread based (Blocking) | Event-driven (Asynchronous) |
| RAM Usage | High (scales with clients) | Low (constant) |
| Configuration | .htaccess (Dynamic) | Global config only |
| Stability | Rock Solid | Good (watch for leaks in old modules) |
The CoolVDS Factor: Why Underlying Tech Matters
Software optimization is useless if your host over-provisions their hardware. Many budget hosts in Europe use container-based virtualization (like standard OpenVZ) where "guaranteed RAM" is a lie. If a neighbor abuses the kernel, your Lighttpd instance stalls.
At CoolVDS, we prioritize stability for the Norwegian market. We utilize Xen virtualization to provide true hardware isolation. When you buy 1GB of RAM, that memory is locked to your kernel. Furthermore, we are beginning to roll out Enterprise SSD storage options. Lighttpd on SSD is a game-changer for I/O heavy workloads, reducing latency to near zero.
Data Integrity and Norwegian Law
Hosting locally isn't just about latency to the NIX (Norwegian Internet Exchange); it's about compliance. With the Datatilsynet (Data Inspectorate) tightening enforcement of the Personal Data Act, keeping your server data within Norwegian borders on a secure CoolVDS instance ensures you aren't caught in cross-border legal grey areas.
Verdict: Which One to Choose?
Choose Apache if: You are hosting a complex dynamic application, rely heavily on .htaccess, or have a team that isn't comfortable rewriting configuration files.
Choose Lighttpd if: You are serving massive amounts of static content, video streaming, or are running on a budget VPS where every megabyte of RAM counts.
(Note: Keep an eye on the emerging Nginx project. Version 1.0 was recently released, and while less mature than Lighttpd, it is showing promise as a robust alternative.)
Ready to test your configuration? Don't let slow I/O kill your traffic spikes. Deploy a Xen-based Linux instance on CoolVDS today and experience the stability of dedicated resources.