The web, as we comprehend it lately, began its world “conquest” within the ’90s. The entire “Internet” protocol may also be summed up as a customer inquiring for a record from a given internet deal with, with DNS and IP gadget forwarding that request to the correct pc. This pc, which is webhosting the asked internet web page, will “serve” the internet web page again to the customer.

Internet pages are necessarily HTML paperwork. With the intention to serve other internet pages to the guests, the “serving” gadget wishes a server program. Device like Nginx vs Apache maintain requests, analyze them, after which hand again the corresponding paperwork to be considered in a customer’s browser.



We’ll dive into Apache first because it used to be launched first.

After Tim Berners-Lee’s CERN httpd and NCSA HTTPd within the first couple of years of the web, Apache – first launched in 1995 – temporarily conquered the marketplace and become the arena’s hottest internet server. These days, it nonetheless is in that marketplace place however most commonly for legacy causes. Apache is being evolved and maintained by means of the Apache Basis, underneath the Apache license.

There are two other tales on how Apache were given its title. One model says that the title originates from the well-known Local American heritage, whilst the opposite says that the title is a pun on “a patchy server”, which adopted a chain of tool patches.


Apache’s massive marketplace proportion is partially because of the truth that it comes pre-installed with all main Linux distributions, like Purple Hat/Centos and Ubuntu.

Ubuntu default page

Ubuntu default web page

One instance of the essential function of Apache inside the Linux international is that its server procedure title is HTTPd, making Apache a synonym with internet server tool.

But even so being the primary severe participant within the internet server marketplace, a part of Apache’s proliferation is because of its configuration gadget and its .httaccess report.


Apache makes use of .htaccess for its configuration. There are many tutorials about how one can configure, edit, and paintings with this report because it supplies a large number of flexibility in configuring how Apache handles incoming requests. Some examples are: other redirection rules, maximum upload file sizes, URL rewrites, memory limits, listing coverage (htpasswd), expires headers, cache-control headers, encoding headers, cookies, question string manipulations.

However, Kinsta makes use of Nginx which doesn’t fortify .htaccess recordsdata. Alternatively, settings and regulations out of your .htaccess recordsdata may also be simply “translated” to Nginx’ personal rewrite rule syntax.

One of the vital major “Execs” of Apache is that within the server root — the primary web site listing — each point or listing within the listing tree will have its personal .httaccess report with its personal configuration.

For shared hosting providers, it is a dream as a result of they are able to supply masses of customers at the identical gadget a method to configure how their web sites are served, with out it affecting the others. Consumers can configure a large number of main points in a limited shared webhosting atmosphere, whilst by no means touching the worldwide server configuration.

Because the authentic documentation says:

“Usually, you will have to simplest use .htaccess recordsdata whilst you don’t have get right of entry to to the primary server configuration report.”

This pliability, alternatively, comes on the expense of efficiency “permitting .htaccess files causes a performance hit, whether or not or now not you in truth even use them!”

Each and every time .htaccess recordsdata are enabled, Apache has to traverse all the listing tree from the asked URL or report via all of the upper ranges up till the server’s root listing after which load them, for every request. It then must procedure those recordsdata and reconfigure itself for every of the directories configured on this approach.

With WordPress web sites, issues can get actually complicated. An ordinary WordPress web site will have masses of requests from other directories.

From /wp-content/uploads/yyyy/mm form of dirs it’ll normally have a couple of requests on a unmarried web page load, continuously shape other month-directories. Then there will likely be /wp-content/subject matters/parent-theme static assets, /wp-content/subject matters/child-theme assets: those will come with javascript, css recordsdata, photographs.

Then there can also be /wp-content/plugins with static recordsdata loaded from continuously dozens of plugin subdirectories. For every of those assets, Apache has to traverse its complete tree to search for the configuration.

One analysis has proven that a standard WordPress setup, somewhat not unusual for web sites on shared hosts, will come with 42 separate .htaccess executions and 249 separate appears to be like for the .htaccess report.

That is simply at a internet server point. The customer nonetheless must look ahead to the PHP procedure to execute all the WordPress name stack to create the database question and provides it to MySQL to gather the internet web page and ship it to the customer.


Some other factor that made Apache widespread is its dynamic module gadget.

Modules — as a function that permits customers to increase internet server capability — exist each in Nginx and Apache. Apache lets in customers to put in modules as soon as the internet server has already been put in and deployed after which enabled/disabled them as wanted. Debian-based distributions have instructions that let enabling and disabling those modules with no need to edit any configuration recordsdata: a2enmod and a2dismod.

The authentic checklist of modules that come as a part of Apache usual distribution is here and those come with issues from compression, encryption, logging, redirections to extra complicated such things as modifying requests and responses with complicated syntax.


Nginx (additionally written as nginx or NGINX), got here at the scene in 2004, when it used to be first publicly launched by means of Russian developer Igor Sysoev. As Owen Garrett, Nginx’ challenge supervisor said:

“Nginx used to be written particularly to deal with the efficiency obstacles of Apache internet servers.”

The server used to be first created as a scaling software for the web site in 2002. It is available in two variations: open supply, with BSD-type license, and Nginx Plus, with fortify and further undertaking options.

After it used to be launched, Nginx used to be used most commonly to serve static recordsdata and as a load-balancer or opposite proxy in entrance of Apache installations. Because the internet advanced, and the want to squeeze each ultimate drop of velocity and {hardware} utilization potency with it, extra web sites began to switch Apache with Nginx totally, thank you additionally to a extra mature tool.

NGINX Inc acquired by F5 Networks

NGINX Inc obtained by means of F5 Networks

In March 2019, Nginx Inc was acquired by means of F5 Networks for $670 million. At that second, as Techcrunch experiences, Nginx server used to be powering “375 million web sites with some 1,500 paying consumers”.

In step with data from w3techs, Nginx marketplace proportion has been often rising, pushing Apache out and dethroning it from the primary position:

Web server usage

Internet server utilization

This information relates to general internet servers globally, but when we take pattern of the highest a million web sites, Nginx has been there for a while now:

Percentage of websites using Nginx

Share of web sites the usage of Nginx

Google Seek Traits turns out to replicate this reality as neatly:

Google Search Trends: Nginx vs Apache

Google Seek Traits: Nginx vs Apache

Netcraft survey suggests that Apache has been overtaken by means of Nginx in April 2019.

Nginx Configuration

Nginx does now not have a configuration gadget like Apache so, regardless of it being much more environment friendly and rapid, it’s not broadly hired with retail webhosting suppliers. It does now not shine in shared environments as Apache does.

However, as we stated, by means of now not permitting directory-level configurations, Nginx features a vital edge over Apache. There’s a piece of writing on Nginx wiki that compares efficiency have an effect on:

Performance impact Nginx vs Apache.png

Efficiency have an effect on Nginx vs Apache.png

Nginx Modules

Nginx modules gadget is yet one more factor that positions it as a extra top class selection. Nginx modules normally want to be enabled at construct time, this means that a extra technical prowess is concerned, and the post-installation including of modules is a little more difficult.

In 2016, with model 1.9.11, things have changed and the authentic/verified dynamic modules repository is reserved to the paying customers. As of Would possibly 2019, they announced beginning the advance of fortify for QUIC and HTTP/3.

The Topic of Caching: Nginx vs Apache

Caching — if we need to oversimplify it — may also be pictured as making ready the content material for web site guests ahead of they talk over with in order that once they “knock at the door”, you don’t want to move search for the content material that they’re in search of. You have already got it ready and also you hand it to them with none ready.

Like Apache, Nginx’ conventional setup was once to take a seat between servers and the tip consumer to alleviate the efficiency hit on the remainder of the infrastructure. In those circumstances, it will possibly cache static content material with out the want to fetch it from the safe, beginning server each time.

If we use Nginx as a standalone internet server — as is the case with Kinsta LXC containers – there is not any such want. Nginx may be very environment friendly in serving static content material by itself.

Then there’s the topic of dynamic cache or page cache. In a WordPress web site’s situation, this implies storing all WordPress pages generated for each URL in reminiscence or on disk.

FastCGI caching is natively to be had in a typical Nginx set up. It’s easy, very robust, and probably the most much less often used Nginx options.

To check this to Apache equivalents, you will have to know that Apache has mod_cache module which reportedly has a tendency to be glitchy, conflicting with different modules. So the usual caching answer deployed with Apache is Varnish HTTP accelerator. Even if Varnish is the devoted trade answer, some contemporary checks give Nginx caching clear edge over Varnish.

At Kinsta, we use Nginx for dynamic WordPress caching, along side a proprietary caching plugin that permits granular keep an eye on over pages cached, and static belongings cached by means of Kinsta CDN.

Are you bored with sluggish WordPress webhosting? We use complete web page caching on the server-level to ship content material on your guests virtually immediately. Check out our hosting plans

Dealing with Requests: Nginx vs Apache

The largest distinction between Apache and Nginx is within the underlying structure of the way in which they maintain requests.

Apache processes requests with MPM-s or Multi-Processing-Modules, which is “answerable for binding to community ports at the gadget, accepting requests, and dispatching kids to maintain the requests.”

The oldest MPM, which dates again all of the method to Apache’s beginnings, is prefork module. This module on my own may also be credited for Apache’ efficiency unhealthy recognition. Beneath this mode, Apache spawns new procedure with one thread on each request.

This module, used with mod_php, intended that Apache server embedded a PHP interpreter in each unmarried procedure, despite the fact that it needed to serve CSS recordsdata or photographs.

This used to be inefficient. Prefork module comes with Apache because the default module. It additionally restricts connections to HTTP/1.

In later years, Apache has evolved multi-threaded worker mpm and after that, the event mpm. Each ot them alleviate a lot of Apache’s efficiency problems. Switching to php-fpm makes it imaginable for Apache to nonetheless be a competing answer lately, along side getting rid of the usage of .htaccess, however that roughly defeats its function.

Nginx makes use of asynchronous, non-blocking event-driven structure.

To provide an explanation for the variation: within the Linux/Unix international, processes are working methods.

Threads are a subset of processes and there may also be a couple of threads inside one procedure execution. Recall to mind this as a couple of tabs in a browser window. This manner a program can leverage a couple of CPU-s and multi-core, multi-thread CPU-s to execute sooner. You’ll learn Linus Torvalds elaborating the differences.

In brief, Apache makes use of processes for each connection (and with employee mpm it makes use of threads). As visitors rises, it temporarily turns into too pricey.

We will be able to image new procedure or thread introduction like booting up of a pc or beginning up methods. Even at the quickest of computer systems, it nonetheless takes a while. With web sites lately making masses of requests on a unmarried web page load, this temporarily provides up.

Match mpm is going slightly additional with regards to optimization, however some tests display that it will possibly’t outrun Nginx. Particularly once we discuss static recordsdata, the place Nginx serves up to double the requests that Apache does.

Nginx preferably has one employee procedure according to CPU/core. The adaptation of Nginx employee processes is that all can maintain hundreds of thousands of incoming network connections per worker. There’s no want to create new threads or processes for every connection.

That is why why main Content material Supply Networks, like Cloudflare, MaxCDN, and our partner KeyCDN — or web sites like Netflix — to find Nginx the most important for his or her content material supply.

The checklist of businesses that make the most of Nginx is simply too lengthy to checklist all of them, so we will be able to finish with Automattic, the non-public corporate in the back of

Automattic transformed all their load-balancers to Nginx for in 2008 (you’ll be able to read about it here) and migrated their server stack completely to Nginx.

Checking It in Actual Lifestyles

If we need to investigate cross-check what the web site in manufacturing makes use of, we generally can to find this within the HTTP reaction headers. This implies we will be able to want to right-click on a web site > Check out, within the developer equipment, we will be able to select the community panel, after which reload the web site. We’ll see all of the assets that the web site is loading. If we select any specific useful resource and its Headers tab, we will be able to generally see the server knowledge. If the web site makes use of CDN, we would possibly see one thing like Cloudflare within the server line or one thing like Varnish if the web site makes use of HTTP accelerator.

That is an instance of a WordPress web site that makes use of a standard shared webhosting setup with CPanel, Apache, and PHP:

Apache http header

Apache HTTP header

This can be a web site on Nginx:

Nginx http header

Nginx HTTP header

At the left facet, if we make bigger it, we will be able to additionally be capable to analyze the time of each useful resource and notice its have an effect on at the general web page load time.


On this article, I involved in Nginx vs Apache and defined the primary architectural variations that helped Nginx gaining extra traction and a focus inside the internet server enviornment. Those are the important thing characteristics that give it the efficiency edge in our resource-hungry trade.

After all, now not each use case has the similar priorities and Apache or different equipment reminiscent of Lighttpd, IIS, LiteSpeed, Caddy may well be excellent answers.

At Kinsta, we use Nginx as a part of our performance-optimized hosting answers for WordPress and WooCommerce. Each and every WordPress web page is housed in its personal remoted container, which has all the tool assets required to run it (Nginx, Linux, PHP, MySQL). The assets are 100% non-public and aren’t shared between some other websites.

The submit Nginx vs Apache: Web Server Showdown seemed first on Kinsta Managed WordPress Hosting.

WP Hosting

[ continue ]