Apache 2: Improvements May Be Obvious, but Upgrade Choices Aren't
Apache 2.0 is a major rewrite of what is often referred to as "the best http server on the planet." As the Apache team modestly states in the release notes: "Apache is the most popular web server in the known universe; over half of the servers on the Internet are running Apache or one of its variants." With Apache version 2 out and about, you might be confronting the question of an upgrade. Carla Schroder discusses why despite all the improvements, in some cases it makes sense to wait a bit and let the dust settle.
A few highlights in the new, improved Apache:
- Apache Portable Runtime library
- Content filtering
- Improved performance for non-Unix platforms
- Hybrid thread/process modes for speed and greater scalability
- MPM: Multiprocessing modules
- Better internationalization
Adding multithreading to Unix versions means a nice performance boost. In a sense, threads are lightweight processes. (Multithreading was already present for Windows and other platforms in the previous version.) Threads are now more efficient; processes are more stable. Processes are rugged individualists, consuming their separate shares of system resources. One process can create many threads, all sharing the same memory space.
Version 2.0 combines threads and processes, in fact an ace administrator can tweak various combinations for best performance. This is done with multiprocessing modules (MPM). These are selected and compiled into the server at configuration. Some MPMs also have configurable runtime options. Unix platforms have three MPM options:
- Prefork: The 1.3 model. Single parent process spawns child processes to handle requests. Spare children are kept sitting around just in case. Excess children are killed off after a prescribed length of time. (This is what the docs say. Really.) This is the familiar old way of doing things, and it permits using thread-unsafe libraries.
- Worker: Hybrid multiprocess and multithreads. Each process has a fixed number of threads, Apache adjusts the number of processes to meet the workload. More efficient and scalable, the one downside is if one thread segfaults, the entire process dies, taking all its threads with it. Because threads share memory space, programs must be written specifically to be "thread-safe."
- PerChild: A fixed number of processes spawn varying numbers of threads. This is the most scalable option. It is also the trickiest -- you can imagine the consequences of one process dying when it is controlling a very large number of threads. Putting thousands of threads each on two processes is possible but probably unwise.
PerChild has another interesting capability: configuring the user ID for various processes and virtual hosts. This presents possibilities in delegating administration chores with limited permissions.
To see what modules are installed, run ./httpd -l
./configure --help shows all configuration options.
The Apache Portable Runtime library permits employing the native API of the host operating system, while preserving a common core code base. Again, improved performance and bug fixes will apply to all platforms at once.