Lightweight Web servers
Special-purpose HTTP applications complement Apache and other market leaders
10 Jul 2007
Recent years have enjoyed a florescence of interesting implementations of Web servers, including lighttpd, litespeed, and mongrel, among others. These Web servers boast different combinations of performance, ease of administration, portability, security, and related values. The following engineering study surveys the field of lightweight Web servers to help you find one likely to meet the technical requirements of your next project.
"Lightweight" Web servers like
The first important aspect is to understand clearly the domain under investigation (see Resources for details). The fundamental end-user action on the Internet is "going to a Web page." At a high level, this involves teamwork between a couple of applications:
All Web users have direct contact with browsers, and there's a corresponding level of zealotry in their selection and analysis. Servers, though, are visible only to the sites' technical staff. Moreover, while there are scores of different Web servers in use, two account for around 90% of all sites, according to recent surveys by Netcraft: Apache and Internet Information Server (IIS). Both of these are highly refined products, boasting not only lengthy intrinsic technologic feature lists, but also thriving "aftermarkets" of books, add-ons, consultancies, providers, and so on. Is there any need to re-invent this particular wheel?
Yes. Important dimensions for evaluation of a Web server include:
Apache and IIS can't optimize so many criteria simultaneously. Abstractly, it's obvious that niche products can surpass the market leaders in at least one or two of these dimensions.
The interesting thing about lightweight Web servers, and what makes them worthy of a survey such as this one, is that their competitiveness is more than just theoretical: Careful examination shows they have a lot to offer and hold their own against Apache and IIS even in many common situations. While it's reasonable to assume the market leaders have been carefully optimized to be effectively unbeatable in performance (for example), many tiny competitors are faster for simple service of static Web pages. When you run your own tests with these Web servers, you'll have the feeling that you showed up at a race track with a go-kart and are somehow passing the Porsches and Vipers. That's not all: There are times when lightweight Web servers complement, and not just compete, with their big brothers. Even if you know you'll be using Apache, you sometimes will get the most from it by teaming it up with a lightweight partner. The best solutions frequently involve co-operation between two or more Web servers.
The "lightness" on which this survey focuses is rather a subjective quality, like "art" or "flavor." It generally means simple, easy-to-install, streamlined, undemanding, and robust -- smaller and less complex than Apache and IIS, certainly, which have grown rather baroque in trying to satisfy their mass markets. For this purpose, the complexity and size of the Java Web Server. AOLserver, and Zeus exclude them, despite their intriguing portability and performance.
Sufficiently lightweight servers open possibilities closed to the market leaders and other "heavy" alternatives. An entire server can fit in one file, for instance. This means it's convenient for a developer to carry around all the tools he or she needs to be productive; even if you run Apache on your production servers, you can sit in a hotel room and experiment with new ideas running on a lightweight server that takes only seconds to install. Also, because they're so undemanding, lightweight servers operate happily on hosts that simply can't stand up under the burden of IIS.
Small, lightweight Web servers also operate quite nicely on low-power hosts. In our own business (Phaseit -- see sidebar), we run dedicated hardware on industrial computers in remote, harsh, or underpowered environments. In those situations, it's a great advantage to be able to serve up Web pages through an application that requires little processing power or disk space; it means that our machines can build in Web-based management consoles, without the development and power overhead of Apache.
Nearly all the lightweight Web servers are open source, at some level. If we need special behavior from a Web server, the ones profiled below are so small that they're easy to understand, and therefore to enhance, with only a couple of exceptions. These Web servers make excellent raw material for projects that embed Web service, whether in special hardware, or in specific applications designed to run on general-purpose computers. They're also in widespread use among conventional-looking Web sites:
Here's an example of the handiness of lightweight servers to
developers: At our company, we work with special-purpose
that provides an office telephony solution. It's based on
customized software that runs as a conventional Linux® application.
With just one additional file and a bit of
Service-oriented architectures (SOA) have the reputation of being difficult and touchy. At least part of that challenge, in our experience, centers on correct Web service. We've taken advantage of lightweight Web servers to set up quick SOAs for demonstrations.
Lightweight servers even have a role to play in production datacenters, including the high-profile sites listed above, and more. Very high-performance sites segment their operations to make the most of caching, proxying, and so on. An Apache-based site, for example, might have an architecture which delivers slowly changing images through a minimal Web server from a dedicated filesystem. The results an end-user sees are actually the outcome of teamwork between Apache and one or more secondary Web servers, each playing a role at which it excels. Such an arrangement can deliver very fast results at minimum computational cost.
While lightweight Web servers have much in common, there's also variation within the category. Most are written in C, but several other implementation languages have proven successful among the servers with which I've experimented, including Erlang, Java, Lisp, Lua, Perl, Python, and Tcl. If there's a language you favor, you can probably find a Web server coded for your convenience.
You might concentrate on a "minority" language for plenty of specific reasons:
Athana exemplifies these themes. It's a Web server coded in Python. It supports HTTP multipart (uploading), sessions, cookies, and more. Athana, as of the 0.2.1 release, is still coded in a single, nicely organized source file.
As hinted above, the strengths of different lightweight Web servers also vary, more or less independently of the language involved. All the lightweight Web servers are smaller and easier to configure than Apache. Some are faster, some much faster, than Apache; others emphasize security, grace under heavy load, extensibility, or memory stinginess. In all cases, it's reasonable to expect to understand these servers thoroughly in a way that's no longer practical with Apache.
What specific products make these possibilities real? Even restriction of attention to "lightweight" servers leaves an unmanageably large collection. Think of them in terms of sub-categories: The ultralightweight, the security-conscious, those which feature a particular language, and so on.
Among these, I'm particularly fond of ultralightweight Web servers, those which are much smaller than Apache. Applications this small can fit inside a single human mind; it's possible to think about them systematically and rigorously, to prove their security or scaling profiles. Tiny Web servers include:
Perhaps the most impressive achievement of the lightweights as a category are the high-performance servers:
A few Web servers are implemented as class or libraries designed to be embedded in larger applications. Among these I've found particularly interesting are:
Python is the language of implementation for several Web servers which fit unusual niches, including:
There are other interesting lightweight Web servers implemented in Perl and other not-so-well-known languages:
And you might someday need a few other C-coded lightweight Web servers with unusual secondary strengths:
There's far more to the world of Web servers than just Apache and IIS. You can find a healthy selection of alternatives so small they can be completely understood, yet fast enough for serious applications. One of them may well help speed your next project.
Get products and technologies