Apache vs Lighttpd

From WikiVS, the open comparison website
Jump to: navigation, search
Apache Lighttpd
http://httpd.apache.org http://www.lighttpd.net

Apache and Lighttpd are open-source cross-platform HTTP servers.


Lighttpd is an asynchronous server. It runs as single process with a single thread and non-blocking I/O.

Nginx and Lighttpd are probably the two best-known asynchronous servers and Apache is undoubtedly the best known process-based server. [...] The main advantage of the asynchronous approach is scalability. In a process-based server, each simultaneous connection requires a thread which incurs significant overhead. An asynchronous server, on the other hand, is event-driven and handles requests in a single (or at least, very few) threads.

While a process-based server can often perform on par with an asynchronous server under light loads, under heavier loads they usually consume far too much RAM which significantly degrades performance. Also, they degrade much faster on less powerful hardware or in a resource-restricted environment such as a VPS.

Pulling numbers from thin air for illustrative purposes, serving 10,000 simultaneous connections would probably only cause Nginx to use a few megabytes of RAM whereas Apache would probably consume hundreds of megabytes (if it could do it at all).


Most tests show that there is an inherent performance increase in using Lighttpd over Apache.

http://www.markround.com/archives/30-LigHTTPd-and-Apache-Symfony-benchmarks.html http://schlitt.info/opensource/blog/0504_apache_vs_lighttpd_echo_performance.html

Though benchmarks can vary depending on modules used; scripting language and platform used, in most cases Lighttpd will outperform Apache.


Virtual Hosts[edit]

Both Apache and Lighttpd support virtual named hosts.


Apache has support for CGI/FastCGI. It is proven and its implementation hasn't changed in years. You might find documentation more than ten years old, and still be valid.

Lighttpd has support for CGI and FastCGI via module. [1] Not only can it retrieve pages from FastCGI processes, it can automatically spawn them. [2]


Both Lighttpd & Apache support XCACHE and APC.


Lighttpd supports X-Sendfile since version 1.5.

Apache 1 does not support X-Sendfile. For Apache2, there is a 3rd party module.


Rewriting in Apache can be handled at a config (site level) or via override in the state of .htaccess. In Lighttpd you're restricted to rewriting via the config level only, which means for things like Wordpress you will need to hard code the rewrite rule in.

A standard config, for wordpress in lighttpd, would resemble

$HTTP["host"] =~ "^(www\.mysite\.co.uk|mysite\.co.uk)$" {

    url.rewrite-once = (
      "^/(wp-.+).*/?" => "$0",
      "^/images/.*/?" => "$0",
      "^/(sitemap.xml)" => "$0",
      "^/(favicon.ico)" => "$0",
      "^/(xmlrpc.php)" => "$0",
      "^/keyword/([A-Za-z_0-9\-]+)/?$" => "/index.php?keyword=$1",
      "^/.*?(\?.*)?$" => "/index.php$1"

    server.document-root = "/var/www/mysite.co.uk/htdocs/"

    accesslog.filename   = "/var/www/mysite.co.uk/logs/access.log"
    server.errorlog  = "/var/www/mysite.co.uk/logs/error.log"


In Apache this rewriting would be handled automatically by the creation of a .htaccess file increasing the learning curve in using Lighttpd but offsetting the extra processing required to 'override' the settings using .htaccess in Apache.


Lighttpd is distributed under the terms of the Revised BSD License, a three-clause, copyfree variant of the BSD License. This licensing choice significantly reduces collaborative friction between Lighttpd code and that of other projects distributed under other licenses, and imposes no notable restrictions on software development related to Lighttpd.

Apache uses the eponymous Apache License 2.0, a license sometimes considered "permissive" in that it is an open source license that is not a copyleft license. It still applies restrictions on software modification and distribution above and beyond that of copyfree licenses such as the Revised BSD License used by Lighttpd, however. The differences include change notification bookkeeping for modified files, as well as substantially more complex license text. A potential benefit of the Apache License 2.0 over the Revised BSD License is the Apache License's patent clause, though the utility of such a clause may be debatable.