Nginx vs Apache – Which one is the Best ?

Filed Under: NGINX

Apache and NGINX are the two most popular and open source web servers used all over the world and controls over 60% of the market share. Although the functionalities of both of them are pretty same, they differ in terms of their architecture, performance, and security along with a few other key points.

However, choosing one of them as a web server is not always easy since both of them are exceptionally well with a great track record.

NGINX vs Apache

Nginx Vs Apache

Nginx Vs Apache

In this article, we will discuss a few key differences between Apache and NGINX to help you select either of them that suits your requirements.

1. Performance

Both Apache and NGINX serves static and dynamic content differently. Apache uses a traditional file-based method for serving static content like CSS, JS or image file. However NGINX offers lot of options to optimize performances for serving static content.

NGINX is better placed at serving static content or media under extreme load. According to some benchmark report, NGINX is 2 times faster than Apache while serving static content.

In case of processing dynamic content like PHP pages, both of them forwards the request to separate environment for PHP. While Apache is directly involved with processing PHP pages but Nginx uses the services of php-fpm to do the same.

NGINX if configured properly with PHP-FPM, can process dynamic content quite efficiently. Apache is also equally efficient in processing PHP pages when multi-processing event modules (mpm_event) is configured correctly with PHP-FPM.

Therefore in case of serving dynamic content, both Apache and NGINX are equally good.

2. Architecture

The design architecture of Apache and NGINX are quite different and it affects the way they handle connections and traffic from clients. Apache is based on the process-driven architecture where it creates a new thread for each connection request. This lead to heavy resource usages during heavy traffic that can cause issues with Apache.

On the other hand, NGINX employs non-blocking event-driven architecture and can serve thousands of concurrent requests with a single thread. In NGINX, a single master process (per CPU) creates multiple worker processes and each worker process has only one thread. As a result, NGINX works very efficiently with limited resources. This is in contrast to Apache where it can handle only one connection with a single thread.

3. Security

When comparing NGINX and Apache in terms of security, Both Apache and NGINX perform exceptionally well with a proven security track record. The mod_evasive and mod_security module of Apache provides an additional layer of security by mitigating DDoS/Brute force attacks and installing a web application firewall respectively.

The Apache Software Foundation follows a proactive policy while dealing with security issues and denial of service attacks against the Apache HTTP server. The foundation also publish security bulletin and encourage users to report any new security issues with Apache.

Like Apache, NGINX also list security updates in its site and advises users to follow few recommended configuration settings to mitigate DDoS attacks.

4. Modules

Both Apache and NGINX can be extended with modules but the way in which functionalities are incorporated using modules are different. There are about 60 modules supported by Apache officially those can be dynamically loaded or unloaded as per your requirements.

NGINX also supports the notion of the module but earlier it was not possible to load modules dynamically into it. The system admins used to compile modules to integrate it to the core. However, in the beginning of 2016 NGINX got the support for dynamic module loading. With dynamic modules, you can optionally load separate shared object files at runtime as modules – both third-party modules and some native NGINX modules.

5. Operating System

Apache supports all major Linux and Non-Linux operating system and works on them perfectly. NGINX also supports Linux and Unix-like operating system but its support to Windows is partial. The performance of NGINX in Widows is also not as robust as compared with Linux.

6. Support

NGINX provides official support for its commercial version NGINX Plus. The commercial version includes few added features in the area of load-balancing, media streaming, and monitoring. For free edition, NGINX offers community support through mailing lists, IRC, and forums.

While Apache does not have any commercial version but all commercial support can be availed through third parties. Like NGINX, Apache also offers community support through mailing lists, IRC and forums.


In general, Both Apache and NGINX excel in their own areas and cannot be replaced by each other. They have their own strengths and weaknesses. In the end, all depends upon defining exact requirements while choosing either Apache or NGINX.

According to Google Trends, NGINX is gained a lot of popularity over Apache in the last 5 years and its market share will cross Apache in the next few years for sure.

Google Trends Nginx Apache

Google Trends – Nginx and Apache

Below table gives you a quick overview when comparing NGINX vs Apache web server.

AreaNGINXApacheWhich is Better?
ArchitectureNon-Blocking Event Driven, requires less CPU and memory.Process driven, create threads for every request, requires more CPU and memory.NGINX
Serving Static ContentNGINX has a lot of options to optimize itApache uses simple file based approachNGINX
Serving Dynamic PHP ContentNGINX uses php-fpm to process PHP pagesApache can process PHP and we can use mpm_event with php-fpm too.Both are equally good.
Resource FootprintNGINX works great with multi-processor environment and uses memory efficiently.Apache requires more memory and CPU in high work load.NGINX
SecurityNGINX configurations are useful to prevent DDoS attacksApache has mod_evasive and mod_security modulesBoth are equally good.
Modules supportNGINX now supports dynamic loading of modulesApache supports a lot of modules that can be dynamically loaded and unloadedBoth are equally good.
Operating System SupportNGINX is great for Unix/Linux systems. However, Windows support is limited.Apache supports all Unix, Linux, Windows OS.If Windows, Apache is better. For others, both are good.
SupportNGINX provides paid support. There is a lot of free community-driven support too.Apache doesn’t have commercial support. However, community support is more than enough to help you.For larger enterprise, NGINX is better as they can get official support. For everybody else, both of them have enough documentation and online resources to cover all your needs.
Generic selectors
Exact matches only
Search in title
Search in content