Apache and Nginx

NGINX vs Apache: Head to Head Comparison

Posted in Apache, Nginx
NGINX vs Apache: Head to Head Comparison

The two most popular open source web servers(Source) powering the Internet today are Apache HTTP server and NGINX. Over 50% of the websites in the world run on these two web servers. For almost two decades, Apache Web server served around 60 percent of the world’s websites until its competitor NGINX (pronounced as “engine-x”) came into existence. Due to the explosive growth in data traffic volumes and the number of users of the world-wide-web, NGINX was introduced to overcome the performance limitations of Apache web servers. NGINX, designed for higher concurrency, can be deployed as a standalone web server, and as a frontend proxy for Apache and other web servers.

Quick Overview of Apache

Apache was developed to deliver web content which is accessed through the internet. It is notable for playing a key role in the initial growth of the World Wide Web. Apache is an open-source software developed and maintained by an open community of developers and it runs on a wide variety of operating systems. The architecture includes the Apache Core and modules. The core component provides the basic server like capability, so it accepts connections and manages concurrency. The various modules correspond to different functionalities that are executed on each request. A specific Apache deployment can be configured to include different modules such as security features, management of dynamic content or for basic HTTP request processing.

“One-server-does-all” model was the key to the early success of Apache. However, as traffic levels increased and web pages became richer and performance was a constraint, tuning Apache to cope with real-world traffic became complex.

NGINX an Overview

NGINX was written specifically to address the performance limitations of Apache web servers. The performance and scalability of NGINX arise from its event-driven architecture. It differs significantly from Apache’s process-or-thread-per-connection approach. In NGINX, each worker process can handle thousands of HTTP connections simultaneously. Hence NGINX is an implementation that is lightweight, scalable and has high performance. This architecture makes handling of high and fluctuating data loads much more predictable in terms of RAM usage, CPU usage, and latency.

NGINX also has a rich set of features and can perform various server roles:

  • A reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols
  • A load balancer and HTTP cache
  • A frontend proxy for Apache and other web servers, combining the flexibility of Apache with the good static content performance of NGINX

Apache vs Nginx: Comparisons on their rich feature sets


Developing and innovating applications on Apache is easy. The one-connection-per-process model makes it very easy to insert modules at any point in its web serving logic. Developers could add code in such a way that if there were failures only the worker process running the code would be affected. Processing of all other connections would continue undisturbed.

NGINX, on the other hand, has a sophisticated architecture hence developing modules is not easy. NGINX module developers need to be very careful to create efficient and accurate code, without any failures, and to interact appropriately with the complex event-driven kernel to avoid blocking operations.


Performance is measured by how the server delivers large volumes of content to the client browser and this is an important factor. Content can be Static or Dynamic.

Let us see some statistics on this.

Static Content

NGINX performs 2.5 times faster than Apache according to a benchmark test performed by running up to 1,000 simultaneous connections. Another benchmark running with 512 simultaneous connections, showed that NGINX is about twice as fast and consumed less memory. Undoubtedly, NGINX has an advantage over Apache with static content. So if you need to serve concurrent static content, NGINX is a preferred choice.

Dynamic Content

For displaying dynamic content, Speedemy’s benchmark tests results revealed that the performance for both Apache and NGINX servers were exactly the same. A probable reason for this is, almost all of the request processing time is spent in the PHP runtime environment rather than the core part of the web server. The PHP runtime environment is pretty similar for both web servers.

Apache can also process dynamic content by embedding a processor of a language like PHP into each of its worker instances. This allows it to execute dynamic content within the web server itself without having to rely on external components. These dynamic processors can be enabled through the use of dynamically loadable modules.

NGINX does not have any ability to process dynamic content natively. To handle PHP and other requests for dynamic content, NGINX must pass to an external processor for execution and wait for the rendered content to be sent back. However, this method has some advantages as well. Since the dynamic interpreter is not embedded in the worker process, its overhead will only be present for dynamic content.

OS support

Apache runs on all operating systems such as UNIX, Linux or BSD and has full support for Microsoft Windows. NGINX also runs on several modern Unix-like systems and has support for Windows, but its performance on Windows is not as stable as that on UNIX platforms.


Both Apache and NGINX are secure web servers. The Apache Security Team exists to provide help and advice to Apache projects on security issues and to coordinate handling security vulnerabilities. It is important to configure the servers properly and know what each option in the settings does. There are many guidelines to secure the servers to prevent security attacks.


Web servers can be customized by adding modules. Apache has had dynamic module loading for the longest time, so all Apache modules support this.

NGINX Plus(NGINX Plus is a software load balancer, web server, and content cache built on top of open source NGINX) uses a modular architecture too. New features and functionality can be added with software modules, which can be plugged into a running NGINX Plus instance on demand. Dynamic modules add functionality to NGINX Plus such as geo-locating users by IP address, resizing images, and embedding Lua scripts into the NGINX Plus event-processing model. Modules are created both by NGINX, Inc. and third-party developers.

Majority of the necessary core module functionality (e.g., proxy, caching, load-balancing) is supported by both web servers.

Support and Documentation

A major point to consider is the available help and support for the web servers among other software. Because Apache has been popular for so long, support for the server is fairly ubiquitous. There is a large library of first and third-party documentation available for the core server and for task-based scenarios involving hooking Apache up with other software.

Along with documentation, many tools and web projects include tools to bootstrap themselves within an Apache environment. This may be included in the projects themselves, or in the packages maintained by your distribution's packaging team.

Apache, in general, has more support from third-party projects simply because of its market share and the length of time it has been available.

For NGINX, in the past, it was difficult to find comprehensive English-language documentation due to the fact that most of the early development and documentation were in Russian. However, today the documentation has been filled out and there are now plenty of administration resources on the NGINX site and available documentation by third parties.

Ngnix vs Apache: Head to Head Comparison

To summarize, here is a tabular view of the feature sets:

Feature Apache NGINX
Simplicity Easy to develop and innovate because of its one-connection-per-process model Complex to develop as it has a sophisticated architecture to handle multiple connections concurrently.
Performance – Static Content Slow in displaying static content 2.5 times faster than Apache and consumes less memory
Performance –Dynamic Content Excellent Performance for dynamic content Excellent Performance for dynamic content
Operating system support Supports all OS – Unix like and Windows Supports all OS – Unix like and windows however performance on Windows is comparatively less stable.
Security Is a secure web server. Understanding and configuring the security features are important Is a secure web server. Understanding and configuring the security features are important
Flexibility Can be customized by adding modules. Apache had dynamic module loading for the longest time. NGINX version 1.11.5 and NGINX Plus Release R11 introduced compatibility for dynamic modules.
Support and Documentation Excellent support and documentation are available as it has been in the market for a very long time. Though there was a weak start for support and documentation for NGINX, it has grown rapidly hence now it has excellent resource support and documentation available.

NGINX and Apache – Working together

For many applications, NGINX and Apache complement each other well. A very common starting pattern is to deploy the open-source NGINX software as a proxy (or NGINX Plus as the application delivery platform) in front of an Apache-based web application. NGINX performs the HTTP-related heavy lifting – serving static files, caching content, and offloading slow HTTP connections – so that the Apache server can run the application code in a safe and secure environment.

So, which one will you go for? Apache or NGINX?

As seen, both Apache and NGINX are powerful, flexible, and capable. The latest versions of both the servers are competitive in all areas. Deciding which server is best for you is largely a function of evaluating your specific requirements and decide the best option.

People are also reading:

Sindhuja Hari

Sindhuja Hari

Sindhuja Hari, a technology geek, content producer & writer brings over 20 years of experience. She builds and delivers best in class content for global audiences. Her favorite domains/ genres are IT, Manufacturing, Logistics & Supply Chain, and Travel & Leisure. View all posts by the Author

Leave a comment

Your email will not be published