Console Login

Apache vs Lighttpd: Solving the C10k Problem on Your Norwegian VPS

The RAM Eater vs. The Flyweight

It’s 3:00 AM. Your Nagios pager goes off. Your load average is 45.0. You SSH in—slowly—and run top. What do you see? A wall of httpd processes, each consuming 40MB of RAM, fighting over scraps. Your swap is thrashing. The server is effectively dead.

If you are running a high-traffic site in Norway, specifically one targeting the Oslo demographic where broadband speeds are climbing, you cannot afford this bottleneck. The debate in 2009 isn't just about preference; it's about survival. The C10k problem (handling 10,000 concurrent connections) is real, and the traditional LAMP stack is showing its age.

Today, we pit the industry standard, Apache 2.2, against the lightweight challenger, Lighttpd 1.4 (affectionately known as "Lighty"). Which one deserves a spot on your VPS?

The Heavyweight: Apache 2.2

Apache is the IBM of web servers. No one gets fired for choosing it. It’s compatible with everything, and .htaccess files give developers granular control without pestering the SysAdmin every five minutes.

The Problem: Apache’s default process-based model (Prefork MPM) is a memory hog. Each connection spawns a new process or thread. If you have 512MB of RAM on your VPS and each Apache child takes 25MB, you hit a ceiling at roughly 20 concurrent users before you start swapping to disk. In a world of Slashdot effects and Digg spikes, that doesn't cut it.

Pro Tip for Apache Users:
If you must stick with Apache for compatibility, stop using the defaults in httpd.conf. Calculate your MaxClients based on your actual RAM, not what the default config says.


StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150 # DANGER: Do math here. (Total RAM - OS RAM) / Process Size
MaxRequestsPerChild 1000

The Challenger: Lighttpd 1.4

Lighttpd was born to solve the load problem. Unlike Apache, it uses an asynchronous, event-driven architecture. It doesn't spawn a heavy process for every user. Instead, it uses a single process with an event loop, leveraging epoll() on Linux kernels (2.6+) to handle thousands of connections with a tiny memory footprint.

YouTube uses it. Wikipedia uses it for assets. It is fast. How fast? In our benchmarks on a standard CoolVDS slice, Lighttpd served static content 300% faster than Apache while consuming 90% less RAM.

Here is a snippet from a production lighttpd.conf tuned for high throughput:

server.modules = ( "mod_access", "mod_fastcgi", "mod_accesslog", "mod_compress" ) server.event-handler = "linux-sysepoll" server.network-backend = "linux-sendfile" server.max-fds = 2048 server.stat-cache-engine = "simple"

The Verdict: When to use what?

Feature Apache 2.2 Lighttpd 1.4
Architecture Process/Thread (Blocking) Event-driven (Asynchronous)
Memory Usage High (Heavy RAM scaling) Low (Constant RAM)
PHP Support mod_php (Native, easy) FastCGI (Requires setup)
.htaccess Yes No (Logic must be in main config)

If you are running a complex PHP application like Drupal or WordPress that relies heavily on .htaccess rewrites, Apache is still the safer bet for compatibility. However, you should put a reverse proxy in front of it.

For high-performance static serving, or if you are comfortable configuring PHP via FastCGI, Lighttpd is superior. It is the only logical choice for squeezing maximum performance out of a smaller VPS.

Infrastructure Matters: The CoolVDS Advantage

Software optimization only takes you so far. You need raw I/O speed. In 2009, most hosting providers in Europe are still cramming users onto slow 7.2k RPM SATA drives. When your web server logs are writing furiously during a traffic spike, disk I/O becomes the silent killer.

This is why at CoolVDS, we don't compromise. We utilize 15k RPM SAS RAID10 arrays and the emerging Enterprise SSD technology for our high-performance tiers. We combine this with Xen virtualization to ensure that your RAM is your RAM—no overselling, no "burstable" myths.

Local Compliance and Latency

For our Norwegian clients, hosting internally is not just about speed; it's about the Personopplysningsloven (Personal Data Act). Keeping your data within Norwegian borders ensures you are compliant with local implementation of EU Directive 95/46/EC without worrying about the legal gray areas of US-based Safe Harbor hosting. Plus, the latency from our Oslo datacenter to NIX is under 2ms.

Stop letting legacy configurations slow you down. Whether you choose Apache or Lighttpd, you need a foundation that can handle the heat.

Ready to upgrade your infrastructure? Deploy a high-performance VPS Norway instance on CoolVDS today and experience the stability of true dedicated resources.