Apache vs Nginx

Everyone has a rival. For Apache, in recent years it has been Nginx, which has significantly improved its position in the field of web servers in recent years. This April (2019) he was even “defeated” by his rival.

Ranking of the most used web servers at the beginning of 2019

Apache was at its peak in 2005 when it was on almost 71% of all websites, but Nginx was not yet in the world. It appeared in the statistics only in 2008 and slowly gained its popularity among server administrators. It was popular mainly with larger projects, and this is evidenced by the statistics from 2018, when 64% of the top 10,000 sites used Nginx and only 21% Apache .

So they must be doing something right. Let’s take a closer look.

VPS Center

Try our server and domain management application for free. You will feel like an experienced administrator.

What is Apache?

The development of the Apache web server began in 1993 at the University of Illinois. Unfortunately, the main programmer Rob Mccool left the team the very next year. There was a slowdown and then a stop to development.

In the meantime, he found a base with web server administrators, and they started supplying him with their own modifications called patches. The name arose from respect and admiration for the indigenous tribe of Native Americans – Apaches and the English specific database by industry phrase “A patchy server” (patched server), once Apache was just a set of patches for another web server. As a Native American symbol, there is a colorful bird feather in the coat of arms.

Logo

A lot of functionality has already been collected by Apache, and many of them are implemented as compiled core extension modules. It supports a number of programming languages, SSL or TLS, proxies or the all-powerful URL rewriter known as the rewrite engine .

Apache provides so-called MultiProcessing Modules (MPM), which allows it to adapt to the system on which it runs. Unfortunately, this means that it is very dependent on the selected MPMs and specific settings .

Types of MPM
event
worker
prefork
If the operating system supports threads and pooling, mpm_event is the best solution. If threads are supported but pooling is not, then mpm_worker is used. In other cases mpm_prefork is used.

What is Nginx?

In 2001, the mod_accel module was developed for Apache, as a replacement for the older mod_proxy. But Igor Sysoev was dissatisfied with the functionality and scalability of Apache and therefore decided to develop Nginx and the first official version was released in 2004.

The goal was clear. To develop a web server that can serve even 10,000 requests at once and with minimal demands on operating memory. There were also requirements for a proxy option, flexible configuration and an implemented cache.

Freelo – Task and project management tool

Join, invite your team and clients, divide the work and watch the tasks go into motion.

 

The result is fast distribution of static content and the possibility of distributing the load to other servers, the so-called load balancing. First, however, he can look in his cache to see if he has the answer with him so he doesn’t have to burden the server unnecessarily.

Nginx can also be used as a reverse proxy for HTTP, HTTPS, SMTP, POP3 and IMAP. You can also use it as a frontend proxy for Apache and use the best of both web servers .

We recommend reading the article on how RAM works on Linux , where we analyze the cache as well.

Performance comparison

Static content
Nginx is 2.5x faster than apache in a test that had 1000 simultaneous connections. With 512 connections, it is 2x faster, and even takes 4% less RAM. This is also one of the reasons why it is mainly used for larger projects – it does not consume so much server resources .

Dynamic content
There is no clear winner when it comes to serving dynamic content, and if both web servers are set up well, they perform equally well. In testing, Apache ran in MPM_worker mode and Nginx ran with the PHP-FPM module.

If you need to increase the speed of dynamic pages, you can add another caching layer. For greater efficiency, you can set up load balancing (multiple web servers handle requests). The last option is to invest in additional hardware.

Web server security

specific database by industry

Both web servers have a good reputation for

security. Nginx has a bigger advantage because it doesn’t have as much code and is easier to maintain more secure.

Nginx maintains an up-to-date list of recent security breaches with detailed explanations. Apache, on the other hand, offers security tips against DoS, how to protect files or secure rights settings.

Flexibility
Web servers can be customized using modules that are ar numbers already created and functional, or you can write your own module, but this is more for administrators in large corporations, where things need to be customized.

Modules for Apache and Nginx
Both offer lots of modules with special features.

Apache modules
Official modules
List of modules on Wikipedia
Nginx modules
Official modules

Third Party Modules

It is impossible to say who has better modules, it generally 6 Reasons Your Cold Emails Aren’t Working comes out the same. Both web servers have options for caching, proxy-ing and load balancing. But Nginx excels more in being used as a reverse proxy for TCP and emails (SMTP, IMAP, POP3).

However, Nginx has one greater advantage in the form of LUA scripting support, which is used by e.g. OpenResty .

Apache and .htaccess

.Htaccess is such an intermediary between the server and the main configuration file. When the web server accesses the website, it first loads .htaccess and takes into account the rules written here.

Nginx has no alternative to .htaccess and every configuration change must be made directly in the configuration file and then reload the webserver.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top