Apache vs Lighttpd
| Apache | Lighttpd | |
|---|---|---|
| |
VS
|
|
| http://httpd.apache.org | http://www.lighttpd.net |
Apache and Lighttpd are open-source cross-platform HTTP servers.
Contents |
[edit] Architecture
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).
[edit] Performance
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.
[edit] Features
[edit] Virtual Hosts
Both Apache and Lighttpd support virtual named hosts.
[edit] FastCGI
Apache has support for FastCGI.
Lighttpd has support for CGI and FastCGI via module. [1] Not only can it retrieve pages from CGI/FastCGI processes, it can automatically spawn them. [2]
[edit] Caching
Both Lighttpd & Apache support XCACHE and APC.
[edit] X-Sendfile
Lighttpd supports X-Sendfile since version 1.5.
Apache 1 does not support X-Sendfile. For Apache2, there is a 3rd party module.
[edit] Rewriting
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 Ligttpd but offsetting the extra processing required to 'override' the settings using .htaccess in Apache.
[edit] Licensing
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.
[edit] Support
[edit] Links
[edit] Benchmarks
- http://schlitt.info/opensource/blog/0504_apache_vs_lighttpd_echo_performance.html
- http://www.howtoforge.com/benchmark-apache2-vs-lighttpd-images
- http://www.howtoforge.com/benchmark-apache2-vs-lighttpd-static-html-files
- http://twilightseo.fallenray.com/php4/lighttpd-fastcgi-php-cli-vs-apache2-mod_php/
