apache vs nginx

Technology review – Apache vs Nginx

The two most popular open source web servers worldwide, Apache and Nginx are responsible for serving over 50% of traffic on the internet.

Even though these software are quite the same, in terms of handling requests, analyzing them, and then sending back the corresponding documents to be viewed in a visitor’s browser, they should not be regarded entirely interchangeable.

Each excels in its own way in managing diverse workloads and working with other software to provide a complete web stack.Also, it is important to understand the situations wherein you might need a thorough evaluation in choosing your web server.

Let us dig deep into the differences between Apache and Nginx and how each server stacks up in several areas.

Tl; dr;

Apache and Nginx are deemed equally close to the pinnacle of the popularity chart as web servers. Both are used by large Fortune 500 companies around the globe and are responsible behind the success of more than half of the websites currently on the Internet.

Most oftenly, Nginx is compared to Apache due to its similar open-source philosophy.

In general, their main difference lies in their design structure.

Apache uses a process-driven approach creating a new thread for each request while, Nginx uses an event-driven architecture handling multiple requests within one thread.

Apache

apache logo

Logo: Apache Software Foundation // Composition: ZDNet

Created by Robert McCool in 1995, the Apache HTTP Server has always been the most popular server on the internet since 1996 and has reached the 100-million website milestone in 2009. It powers up to 52% of all websites worldwide.

This web server is commonly picked by administrators for its flexibility, power, and widespread support, having extensive dynamic loadable module system and can process a large number of interpreted languages without the need of connecting out to a separate software.

Due to its popularity, Apache benefits from great documentation and integrated support from other software projects.It is commonly used in the LAMP (Linux, Apache, MySQL, PHP) web stacks found on shared hosting servers and has a rich set of features that can be enabled by installing one of the 60 official modules.

Nginx

nginx logo

Source: NGINX

An answer to the so-called C10K Challenge – “How do you design a web server which can handle ten thousand concurrent connections?,” Nginx (pronounced “EN-jin-EKS”, or “Engine X”) was developed in 2002 by Russian developer Igor Sysoev but was then publicly released in 2004.

As Owen Garrett, Nginx’ project manager said, “Nginx was written specifically to address the performance limitations of Apache web servers.”

This simply explains that compared to earlier servers such as Apache, Nginx is innovated in using an asynchronous, event-driven architecture and uses the LEMP stack (Linux, “En-juhn-ex,” MySQL, PHP).

In March 2019, NginxInc was acquired by F5 Networks for $670 million and at that point, as Techcrunch stated, Nginx server was powering “375 million websites with some 1,500 paying customers”.

Battle Ground: Apache vs. Nginx

Growing popularity. More than 65% of websites were based on Apache up until 2012 and is greatly regarded as among the first software that pioneered the growth of the World Wide Web (WWW) – its popularity is gained through this historical legacy.

But that dramatically changed.

The popularity gap between Apache and Nginx is closing very fast. According to W3Tech.com, as of January 14, 2019, Apache (44.4%) is just slightly ahead of Nginx (40.9%) in terms of websites using their servers.

server popularity ranking

Fastness. A good web server should run at great speed and can respond to connections and traffic anywhere easily.

In terms of server speeds, a documented experiment was made on two popular travel websites based on Apache (Expedia.com) and Nginx (Booking.com).

Measured via an online tool called Bitcatcha, the comparisons were made for multiple servers and measured against Google’s benchmark of 200 ms.

The results were astounding.

Booking.com (Ngnix) was rated “exceptionally quick,” whereas Expedia.com (Apache) was rated “above average and could be improved.”

Security level. In terms of security, you can guarantee great protection from DDoS attacks, malware, and phishing because both take security measures seriously on their websites. The two release security reports and advisories periodically.

Concurrency features.Another test was conducted and again compared on Booking.com (Nginx) with Expedia.com (Apache) based on stress tests at Loadimpact.com.

As for 25 virtual users, the Nginx website was able to record 200 requests per second, which is 2.5 times higher than Apache’s 80 requests per second.

Therefore, for a dedicated high-traffic website, Nginx is definitely a good choice.

Versatility. A good web server should be flexible enough to allow customizations. Apache does it quite well using .htaccess tools that allows decentralization of administrator duties, which Nginx does not support. That’s why Apache is far more popular with shared hosting providers.

Summary

Overall, we can all say that Nginx narrowly wins the match 2-1, but these comparison on technical parameters can’t definitely suggest the full picture. Thus, both web servers are useful in their own ways.

Apache has .htaccess file that is more convenient, with lots of dynamic modules. Ngnix is popular for VPS hosting, dedicated hosting, or cluster containers.

By Tuan Nguyen

Leave a Reply

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