Apache Talking IPv6
IP version 6 (IPv6) is the newest version of the Internet Protocol, designed by the IETF as a successor to IP version 4 (IPv4). In this article, we address the case of running the Apache web server over IPv6.
According to the Netcraft web server survey, Apache has been the most popular web server on the Internet since April 1996. Currently, over 56% of all web servers run Apache. These numbers come as no surprise due to Apache's portability over multiple platforms, reliability, robustness, configurability, and the fact that it is free and well documented.
Apache 1.3 has established itself as a high-performance web server. However, with the evolution of requirements imposed on web servers, new functionalities, such as higher reliability, security and performance and scalability are required. In response, Apache continued its drive to satisfy these new requirements with version 2.0, promising a more robust and faster web server with new and enhanced functionalities.
Apache 2.0 offers numerous performance improvements (the subject of an article I wrote for the Linux Journal web site, www.linuxjournal.com/articles/4559). However, as far as this article is concerned, one of the new features is support for IPv6. With the 2.0 version, if you run Apache on systems where IPv6 support exists, Apache gets IPv6 listening sockets by default. Additionally, the Listen, NameVirtualHost and VirtualHost directives also support IPv6 numeric address strings.
In the following sections, we demonstrate how to add support for IPv6 in the Linux kernel and then show how to install the latest Apache version and run it with IPv6 support. We also run some benchmarking tests to compare the performance of the same server servicing requests using IPv4 and IPv6.
In this section, we briefly describe how to enable IPv6 in the Linux kernel, a prerequisite to enable IPv6 HTTP requests. You may already have IPv6 support in your kernel [see page 64]. To add it, the first step is to download a stable Linux kernel and uncompress it. For our testing we downloaded kernel 2.4.8 from kernel.org.
We configured the kernel to enable support for IPv6. There are two options you need to enable. In the Code Maturity Level section, you need to enable "Prompt for development and/or incomplete code/drivers".
And in the Networking Options section, you need to enable "IPv6 Protocol (EXPERIMENTAL)".
You can choose to compile the IPv6 support within the kernel or as a separate module, depending on your preference. After that, compile and install the kernel and modules as usual, then reboot with IPv6 support.
See the Kernel HOWTO for details on the kernel build and install process (www.tldp.org/HOWTO/Kernel-HOWTO.html).
Now that your kernel supports IPv6, you are ready to install Apache and run it with IPv6 support. First, download the latest Apache distribution from www.apache.org/dist/httpd into /tmp. For illustrative purposes we use Apache 2.0.16; however, the same procedure applies to newer versions. Extract the source:
cd /tmp tar xzvf httpd-2_0_16-beta.tar.gz
which will create a new directory, httpd-2_0_16, containing the source code. To configure Apache for your platform and specific requirements, use the configure script included in the root directory of the distribution. You should cd into the httpd-2_0_16 directory and type ./configure at the shell prompt. If you want to know all the options you could pass to the configuration script, type ./configure --help. To change the default options, the configure script accepts a variety of variables and command-line options. One of the options is the location prefix where Apache is to be installed. By default, Apache will install into /usr/local/apache. If you want to install Apache in /usr/local/apache-2_0_16, for instance, type:
./configure --prefix=/usr/local/apache-2_0_16The same applies for other options. When configure is run it will take a few seconds to test for the availability of features on your system and build Makefiles that will be used to compile the server. After running the configuration script, you can build the various parts that form the Apache package by running make && make install. This will compile Apache and install all the files in /usr/local/apache-2_0_16. The next step is to customize the Apache HTTP server by editing the httpd.conf file under /usr/local/apache-2_0_16/conf or, if you have used a different prefix, under prefix/conf/:
vi prefix/conf/httpd.confThe must-edit configuration variables include ServerAdmin, your e-mail address (so you will be alerted in case the server has problems); ServerName, the name or IP of the server; and Port, the port to which the server should listen.
The httpd.conf comes with a lot of explanations, and it is easy to read, understand and customize. However, if you need more details on the configuration directives, you can read the Apache manual either locally under the docs/manual/ in the Apache installation directory or on the Web at httpd.apache.org/docs.
Now you have compiled, installed and customized the Apache configuration. As we mentioned previously, IPv6 support is now included within the Apache source code, so you do not need to do any special configuration to activate it. To start the server, you can use the Apache Control Script that is designed to allow an easy command-line interface to control Apache. Using it you can start the server, stop it, restart it, check its status and do a configuration syntax test. Therefore, to start the server you would type apachectl start, and then you should be able to request documents via http://ServerName or http://localhost/.
With the advent of 128-bit addressing comes the pains of typing long IP addresses. The correct syntax of an IPv6 address is eight fields of four hexadecimal characters separated by colons, totaling 128 bits. Note that in URLs, port numbers can be appended to addresses following a colon, like this: 220.127.116.11:80. Since IPv6 addresses already make use of the colon within the address itself, the address in an IPv6 URL is enclosed in square brackets and the colon and port appended after the closing square bracket, like this: [3ffe:200:8:1000:250:bbff:fe00:25]:80.
Not all web browsers are capable of parsing IPv6 addresses. Netscape Navigator 6.x and Mozilla are the two tested browsers that do support IPv6 addresses. We believe that although their support for IPv6 is not yet mature (as they sometimes freeze and require killing the browser process or restarting it), both of them do allow successful parsing of aliased hostnames. Aliased hostnames are hostnames assigned to a unique IP address in /etc/hosts file. For instance, we can define aliases for IPv6 address by editing /etc/hosts as follows:
::1 node02-v6-localhost 3ffe:200:8:1000:250:bbff:fe00:25 node02-v6
When we start Netscape or Mozilla, we type in the defined aliases as the URL and use these aliases to request a web page over IPv6, such as http://node2-v6/ or http://node2-v6-localhost/.
To benchmark the performance of Apache, we followed the above steps to install the latest kernel with IPv6 support and install Apache 2.0.16. The machine is a 1U Celeron 500MHz rackmount unit with 256MB of RAM. It runs Red Hat 7.0. As for benchmarking, we used ApacheBench, a tool that comes free with the Apache web server.
We ran two tests: Apache 2.0.16 over IPv4 and then Apache 2.0.16 over IPv6. For comparison's sake, we ran the same tests on another machine with the same setup, except with Apache 1.3.19, to be able to compare the performance and support for IPv6 in the two versions. To enable IPv6 with Apache 1.3.19, we downloaded the IPv6 Apache patch from the Kame Project web site and applied it to the 1.3.19 source tree. Next, we ran the configure script:
and enabled the INET6 option. Lastly, we did a make && make install, which compiled and installed Apache 1.3.19 with IPv6 support from Kame.
Table 1 shows the results of the benchmarking tests. Each of the benchmarks was the result of 1,000 requests with a concurrency level of 1. There were no failed requests or write errors.
There are few remarks regarding the results. Apache 1.3.19 was able to serve more requests per second than Apache 2.0.16. In the tested versions of Apache, we had fewer requests per second in IPv6 compared to IPv4; this may be due to the fact that the IPv6 code added to Apache has not been tested and debugged thoroughly. On the other hand, if we examine the transfer rate of Apache 1.3.19, we notice that it is much higher than the transfer rate of Apache 2.0.16. This still needs to be investigated.
At the Ericsson Open Architecture Research Lab, we currently have a benchmarking environment to test the performance of our Linux clusters and application servers (including Apache, Tomcat and Jigsaw web servers). However, the environment and the tests are designed to work with IPv4, not IPv6. Our plan is to port the environment to generate IPv6 HTTP requests in order to test the performance of Apache (and other web servers) with IPv6 under heavy load. We currently have a total of 100 1U rackmount units (a mix of Celeron 500 and Pentium III machines with 256MB and 512 MB of RAM) that soon will be generating IPv6 traffic with one node collecting and compiling the results. We will publish our results as soon as the work is completed. This will be more comprehensive than the preliminary testing that was done for the purposes of this article.
IPv6 is becoming a reality. For the next few years, we need to be able to support both IPv4 and IPv6 on our application servers before the complete transition to IPv6 occurs. The developers of Apache are aware of this, and they have already built in support for IPv6 in the Apache code. Previously, the support for IPv6 was in the form of a downloadable patch (from the Kame Project, for instance) that you would apply to the source tree.
As the benchmarking results suggest, serving documents over IPv6 is slightly slower (in terms of requests/second) than serving them over IPv4; however, this is understandable because the IPv6 support is still in its early stages. As the development advances, Apache is expected to reach and exceed the level of performance it achieved with IPv4 to remain the preferred web server in the world.
Ericsson Research (Open Architecture Research Lab) for supporting our work with Linux and open-source software and for approving the publication of this article.