Console Login
Home / Blog / Server Administration / Apache vs. Lighttpd: Surviving the C10k Problem on Norwegian Infrastructure
Server Administration 8 views

Apache vs. Lighttpd: Surviving the C10k Problem on Norwegian Infrastructure

@

The Memory Hog vs. The Speed Demon

Let’s be honest. If you are running a standard LAMP setup (Linux, Apache, MySQL, PHP) on a VPS with 512MB or even 1GB of RAM, you have likely seen the dreaded "Out of Memory" killer in your logs. It’s 2010, and traffic spikes are getting steeper. The old way of throwing more hardware at the problem is getting expensive, especially with the premium on high-performance storage.

For decades, Apache has been the undisputed king of the internet. It is compatible with everything, documents are everywhere, and .htaccess files make life easy for developers. But Apache has a weight problem. Lighttpd (pronounced "Lighty") has emerged as the lightweight contender, promising to handle 10,000 parallel connections (the C10k problem) without bringing your server to its knees. But is it stable enough for production environments in Norway?

The Architecture Bottleneck: Prefork vs. Event-Driven

To understand why your server load spikes, you have to look at how these daemons handle connections.

Apache (MPM Prefork): By default, Apache 2.2 uses the Prefork MPM (Multi-Processing Module). It spawns a separate process for every single incoming connection. If you have 200 concurrent users, you have 200 Apache processes. Each process consumes a chunk of RAM (often 20MB+ if you load heavy PHP modules). Do the math. 200 processes x 20MB = 4GB of RAM just for the web server. If you don't have that, you swap to disk. Once you swap, your site is effectively down.

Lighttpd (Asynchronous): Lighty uses a single process with an event-based architecture (leveraging epoll on Linux kernels). It handles thousands of connections in a single loop. It doesn’t need to clone itself 200 times. The memory footprint remains tiny, often under 20MB total, even under load.

Configuration Showdown

Let's look at the config required to make these servers perform. We tested this on a CoolVDS Virtual Dedicated Server running CentOS 5.5.

Apache 2.2 Tuning

In /etc/httpd/conf/httpd.conf, you must limit Apache so it doesn't eat all your RAM. The default settings are usually too aggressive for a VPS.

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    # Prevent OOM by capping this strictly based on your available RAM
    MaxClients          150 
    MaxRequestsPerChild 4000
</IfModule>

Lighttpd Setup

In /etc/lighttpd/lighttpd.conf, the magic happens with the event handler. This is why Lighty is fast.

server.max-worker = 1
server.event-handler = "linux-sysepoll"
server.max-fds = 2048
server.stat-cache-engine = "simple"
server.network-backend = "linux-sendfile"
Pro Tip: If you are serving heavy static assets (images, CSS, JS), Lighttpd is exponentially faster because of sendfile() support. It pushes files directly from the file system to the network card buffer, bypassing the CPU context switches entirely.

When to Use What?

I recently migrated a high-traffic news portal targeting Oslo users from Apache to Lighttpd. The latency dropped from 400ms to 80ms. However, it wasn't a drop-in replacement.

Feature Apache 2.2 Lighttpd 1.4
PHP Handling mod_php (Easy, but heavy) FastCGI (Requires spawn-fcgi)
.htaccess Native Support Not Supported (Must rewrite to lighttpd.conf)
Memory Usage High (Process per user) Extremely Low (Event loop)
Stability Rock Solid Good, but watch for memory leaks in older versions

The "CoolVDS" Factor: Hardware Still Matters

Software optimization can only save you so much. If your underlying storage I/O is slow, your database (MySQL/PostgreSQL) will bottle-neck long before the web server does. This is where the physical infrastructure becomes critical.

At CoolVDS, we don't oversell our nodes. We use high-performance RAID storage and ensure dedicated RAM allocation via KVM virtualization. In a shared hosting environment (or poorly managed OpenVZ containers), a "noisy neighbor" can steal your CPU cycles, making your optimized Lighttpd config useless.

Furthermore, for Norwegian businesses, data sovereignty is becoming a serious topic under the Personopplysningsloven (Personal Data Act). Hosting your data on servers physically located in Oslo or nearby European hubs ensures you aren't just fast—you're compliant with Datatilsynet's strict expectations.

Conclusion

If you need drop-in compatibility and rely heavily on .htaccess rules for a CMS like WordPress or Drupal, stick with Apache, but tune your MaxClients carefully. However, if you are building a high-performance custom application or serving massive amounts of static media, Lighttpd is the superior choice in 2010.

Don't let slow I/O kill your SEO rankings. Deploy a test instance on CoolVDS today and experience the difference of true hardware isolation.

/// 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