Console Login
Home / Blog / Server Administration / Apache vs Lighttpd: The Battle for Concurrency in 2011
Server Administration ‱ ‱ 8 views

Apache vs Lighttpd: The Battle for Concurrency in 2011

@

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 your httpd.conf, lower your KeepAliveTimeout to 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.

/// TAGS

/// RELATED POSTS

Surviving the Spike: High-Performance E-commerce Hosting Architecture for 2012

Is your Magento store ready for the holiday rush? We break down the Nginx, Varnish, and SSD tuning s...

Read More →

Automate or Die: Bulletproof Remote Backups with Rsync on CentOS 6

RAID is not a backup. Don't let a typo destroy your database. Learn how to set up automated, increme...

Read More →

Nginx as a Reverse Proxy: Stop Letting Apache Kill Your Server Load

Is your LAMP stack choking on traffic? Learn how to deploy Nginx as a high-performance reverse proxy...

Read More →

Apache vs Lighttpd in 2012: Squeezing Performance from Your Norway VPS

Is Apache's memory bloat killing your server? We benchmark the industry standard against the lightwe...

Read More →

Stop Guessing: Precision Server Monitoring with Munin & Nagios on CentOS 6

Is your server going down at 3 AM? Stop reactive fire-fighting. We detail the exact Nagios and Munin...

Read More →

The Sysadmin’s Guide to Bulletproof Automated Backups (2012 Edition)

RAID 10 is not a backup strategy. In this guide, we cover scripting rsync, rotating MySQL dumps, and...

Read More →
← Back to All Posts