There has been a lot of discussion regarding which of the two most popular Web servers is better. In this article, we will try to compare their characteristics and performance.
With the market share of 42% (according to a NetCraft survey in April 2014), Apache is the most widely-used Web server. It is free and open-source software that can be used on any operating system, including Linux, Unix, Windows and Mac OS.
Bug fixing and the development of new features is handled by the developer community and managed by the Apache Software Foundation, a nonprofit corporation which supports the Apache Web server.
Apache is a very feature-rich Web server. Features are introduced as modules that extend the core functionality. Some of the modules come with Apache itself, while others can be manually installed. Since the code is open, anyone can create and publish a new module with additional functionalities.
Apache Web server is part of the LAMP stack — it is usually installed on Linux operating systems, while the applications are developed in PHP with MySQL databases.
Although Apache Web server has generally good performance, it consumes a lot of CPU and memory because of the two main reasons. One reason is a big number of included features which are not being used, while the other is the fact that it is a process-based server. That means that each connection requires a separate thread.
Microsoft IIS is a Web server with the second largest market share (32% according to the same survey mentioned above). The server itself is free, but it can run only on Windows operating systems, thus incurring indirect licensing costs.
IIS is a proprietary software, meaning that the code is closed and not available to public. New features, bug fixes and support is provided by Microsoft. Although the development is not as quick as with the community support, it can be more reliable.
Microsoft IIS handles has a good number of features. Similar to Apache, features are included as extensions. However, IIS extensions are developed only by Microsoft.
Unlike Apache, IIS is installed on Windows operating systems and its applications are using ASP.NET and MSSQL databases.
According to some tests, IIS is faster than Apache (though still slower than nginx). It consumes less CPU, has better response time and can handle more requests per second. However, it should be noted that the tests are not 100% reliable, as they are usually running on a different software stacks (IIS applications are using .NET framework on Windows, while Apache is usually running PHP applications on Linux operating systems).
The test will be performed with different numbers of clients, requests per client and requests per second.
Both Web servers will use the same hardware on AWS free-tier instances:
- Intel Xeon CPU — 2.4 GHz
- 1GB RAM memory
Apache virtual machine will have the following software:
- Ubuntu 14.04
- PHP 5
On the other side, IIS machine's software will look like this:
- Windows Server 2012
- IIS 8.0
- ASP .NET 4.5
The test will measure the following parameters:
- Latency response time (in ms) — the time between sending the request and receiving initial response
- Sample time (in ms) — the time needed to fully serve the request i.e. latency + response
Measurements will be taken by using a popular benchmarking tool — Apache JMeter. JMeter will be configured to run 20 connections spread over 10 seconds, i.e. 2 requests per second. Note that the result numbers should be only compared between the Web servers and not viewed as absolute numbers, as the number of simultaneous connections depends on the PC on which Apache JMeter is running.
In this test, Apache was significantly faster than IIS in both latency and response time in all categories. For further research, it would be interesting to run the same test on more powerful hardware configuration. It would also be interesting to compare the speed of a PHP 7 application on Apache 2 and ASP.NET application on IIS 8.