Web Server Side

Server-Side Web Report – Nginx

Abstract 

Nginx is a web server first publicly released in 2004 by Russian, Igor Sysoev. This article will discuss the main role of Nginx in today’s array of different popular web servers and will consider why it has grown so much compared to other web servers such as Apache by comparing their features and looking at the features which make it appeal to the most popular sites on the web, where Nginx is showing the most growth. The article will also discuss future developments of Nginx and how these will continue to fuel its growth into the near and far future.

Introduction to Nginx

As already mentioned, Nginx was released in 2004 and since then has grown into the second most-used web server across all websites we know. For a while it powered many heavily loaded Russian sites such as Yandex and VK but now Nginx powers many of the world’s largest sites and that number is still growing, with Netflix, GitHub, AirBnb and Pinterest all using Nginx to name a few. It is compatible with several different software stacks by the most popular is the LEMP stack, which uses a Linux operating system, Nginx web server, a MySQL or MariaDB database and Perl, PHP or Python scripting languages.

NGINX does not have the ability to process dynamic content natively and instead passes requests for dynamic content to external processors which execute and pass the results back. This means that communication must take place between Nginx and the processor using a protocol that it knows such as FastCGI. This can be complicated because it increases the number of connections and makes said number much more unpredictable. There is no similar overhead for static content which can be served in a normal manner, offering a performance increase on static content when compared to other servers.

Nginx is also not as flexible as some other servers because it does not offer dynamic module loading, instead making the administrator select and compile them into the software, meaning that if a non-standard module is needed, it will need to be added manually. Nginx modules are still very useful however, and can be used for encryption, mail, streaming and many more functionalities.

According to Netcraft, as of October 2017, Nginx has a 29.43% market share on the million busiest sites on the web and had the largest monthly growth in this same category, with the market leader Apache falling by a slightly smaller rate, this can be seen in the graph below:

As the graph on the above shows, Nginx is the only single web server that is growing in usage within the month of October 2017, a trend that has carried on for many months before too (other servers are growing in popularity but none of them are popular enough to challenge the market leaders on their own). Of all the sites on the web, Apache is still the market leader, but Nginx has a 35.9% market share despite being around for significantly less time.

The graph above has a note which says that a website may use more than one web server, this is important in this case because a number of sites use both Nginx and Apache, with Nginx acting as a reverse proxy, sending dynamic content to Apache for processing and processing static content quickly and handing it right back to the client.

Feature Comparison

Nginx focuses on outperforming Apache, and as already mentioned performs static content serving much faster than Apache, with some tests showing that Nginx can handle 4x more requests per second than Apache with a lower memory footprint. Also mentioned above is that Nginx can act as a reverse proxy and allows for caching while doing so. When processing dynamic content Nginx needs to hand off the processing to an external processor which requires the use of Common Gateway Interfaces, hence Nginx supports the use of FastCGI, SCGI and uWSGI. It is also IPv6 compatible and supports both Name and IP address based virtual servers for the hosting of multiple sites.

The main difference between Nginx and Apache is the way they handle dynamic and static content, with Nginx handling static content faster, and Apache handling dynamic content faster. Most server applications actually have very similar features however, as shown in the table below, which is a comparison of Nginx, Apache and Microsoft ISS :

Feature Nginx Apache Microsoft IIS
Basic Access Authentication Yes Yes Yes
SSL/TLS https Yes Yes (via modules) Yes
Virtual Hosting Yes Yes Yes
Common Gateway Interface No Yes Yes
FastCGI Yes Yes Yes
Internet Server API No Yes Yes
IPv6 Yes Yes Yes
Admin Console Yes Yes Yes

 

As expected the main difference between Nginx and the popular Apache and Microsoft ISS is that Nginx doesn’t natively handle dynamic content, which is why Apache remains the market leader but is often being used in conjunction with Nginx, in order to make the most of the best parts of both servers.

Discussion

Static sites are often used when websites don’t need to be updated very often, or are only updated by an administrator proficient with HTML, but nowadays websites are often attached to databases and contain scripts which allow for dynamic changes and input and output by users and administrators. This is leading to the need for fast dynamic content processing by web servers and is likely why Apache is still market leader. Despite this, web servers still have to handle and serve a lot of static content and requests.

This means that a combination of Nginx and Apache is becoming more popular, leading to an increased market share for Nginx, with Nginx working to process the static content while Apache handles the dynamic content because it has built in CGI, whereas Nginx has to use external modules such as FastCGI and is not as fast.

As more websites want to host web based applications, Nginx will continue to develop and has recently released the NGINX Unit application server in a beta state. The asynchronous handling of traffic will continue to be important going into the future. With more and more people visiting the worlds most popular sites and requesting more and more information from them the processing of the content will need to get faster, happen in parallel and be served back to the user quickly even if they are processing gigabytes every minute.

References:

https://w3techs.com/technologies/overview/web_server/all – Accessed 14/11/2017

http://nginx.org/en/ – Accessed 14/11/2017

https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations – Accessed 14/11/2017

https://help.dreamhost.com/hc/en-us/articles/215945987-Web-server-performance-comparison – Accessed 14/11/2017

https://httpd.apache.org/docs/2.4/mod/ – Accessed 14/11/2017

https://www.iis.net/learn – Accessed 14/11/2017