Which Is the Best Web Server? (2021)

Which Is the Best Web Server? (2021)

While there are lots of different types of server software, you’ll often whittle the contenders down to Nginx vs Apache. This is because both offer top performance for many different server configurations, and suit certain applications better than the other.

Even so, you’ll still want to consider which one of these makes more sense for your needs. There are a few different categories to look into, such as operating system (OS) support, security, documentation, and (of course) performance.

For this post, we’re going to compare Nginx vs Apache in a number of different areas. At the end, we’ll summarize our findings and give you the information you need to choose the right option.

Introducing Nginx and Apache

Before we get into the deep details of each server type, let’s give you the rundown on both Nginx and Apache. Once we get to the next section, you’ll learn about some of the use cases of both, and where you might see them ‘in the wild’.


The Nginx logo.

Compared to Apache, Nginx (pronounced “engine X”) is a relative newbie to the world of server-side technology. However, the development team took on the task of expanding upon the limitations of Apache systems.

It’s an open-source solution that lots of users consider for its stability and scalability. This is (in part) down to its event-driven architecture – more of which later. In fact, part of the goal for the initial Nginx release was to be able to handle 10,000 connections at once. This is something that was necessary back in 2004, due to the rapidly-expanding web at the time.

On the whole, sysadmins and site owners like Nginx because it’s performant, works great with static files, and performs the functions of a load balancer and a ‘reverse proxy’. These are all relevant to uptime, speed, and security.


The Apache HTTPS Server logo.

Apache is somewhat the ‘old man’ of web server technology. It’s almost as old as the web itself – from 1995 Apache has been the software at the core of thousands, if not millions, of servers.

For a long time, Apache has been a dominant technology among ‘sysadmins’. There are lots of reasons for this – some performance-related, and others force of habit. Regardless, Apache servers see lots of use where configurations matter.

You’ll find Apache as pre-installed software on all Linux distros, so it’s a go-to solution for that OS. However, while it uses a different architecture to Nginx, it still offers power, scalability, and fantastic documentation.

Lots of sysadmins also like the customizable nature of Apache, and how you can make a server your own through loading various modules.

The general use cases for Nginx vs Apache

It’s fair to say that Apache is a “jack of all trades” when it comes to serving websites. However, this is a mixed blessing. Yes, Apache servers can do almost everything Nginx can do, but it’s at the expense of less performant code. Age is a factor here.

Because Apache arrived at a time before we have some of the more advanced applications for web servers, the codebase couldn’t do what it needed to serve modern websites. While these issues aren’t necessarily a cause for concern now, a solution such as Nginx works with the modern web in mind.

As such, you’ll find Apache is fantastic as an easy-to-configure server for applications such as shared hosting. Its integrations also see it used as local development server software, as part of the Linux, Apache, MySQL, and PHP (LAMP) stack.

The logos for all of the parts of a LAMP stack: Linux, Apache, MySQL, and PHP.

In contrast, Nginx has a more mature software base, with greater streamlining compared to Apache. It’s good where stability and security are key, fundamental elements. You’ll find that an Nginx server isn’t as configurable as other types, and this means you will access its core less.

What’s more, it’s not modular in the same way that Apache is, which makes it less suitable for a situation where you need to carry out server customization.

Nginx vs Apache: How popular each server type is

For a long time, server software was akin to a one-horse race. Apache ran as a dominant force for a number of years and still holds a huge market share. Because of this, you’ll find there are lots of integrations and support for Apache servers, along with top-notch documentation.

This serves as further reason to choose Apache and contributes to its continued use. However, Nginx is server software with a massive market share of its own. There is a slow rise in Nginx usage over time, to the point that it’s now the most dominant web server technology on the market, although not by much.

Looking ahead, we’d suggest that Apache will see less use over time because Nginx provides a lot of what sysadmins need in a web server. However, LiteSpeed Web Server and Cloudflare Server are on the horizon and come with a growing user base and heavy backing. In a few years, this comparison could compare Nginx to one of these younger upstarts.

Nginx vs Apache: A technical breakdown of the features and functionality

The next few sections will cover a number of technical aspects of Nginx vs Apache. While we can’t cover everything, we’ll give the major areas ample time. In any case, because these represent the core elements of both server types, you’ll have more than enough to go on when it comes to choosing the right software for you.

1. Connection and request handling

How a server handles connections is vital to know because this is its ‘core currency’. It’s arguable, but when people look to discuss the relative merits of Nginx vs Apache, connection handling plays a big part in the perceptions.


Nginx is ‘asynchronous’ and ‘event-driven’, which means it can handle multiple requests at once and process them while there are available resources. It spawns ‘worker processes’ to handle the incoming connections, of which it expects thousands at a time. These are the ‘water carriers’ for the rest of the server.

For example, each worker process will listen out to process events and connections, and add them to a continuous loop. From there, the server can process each event and remove it when it finishes. The flow of an Nginx server provides inherent scalability, and the async, non-blocking architecture serves that too.


In contrast, Apache handles events one at a time through a number of Multi-Processing Modules (MPMs). A sysadmin will choose the connection architecture best suited to the task, of which there are a few.

The mpm_prefork module is a common one. This spawns child processes for each event, and will only process one connection at a time. If the number of processes is higher than the number of requests, you’d struggle to tell the difference between Nginx vs Apache with regard to performance.

However, this type of situation is rare, and an Apache server will see a higher number of requests than processes on many occasions. What’s more, this MPM doesn’t scale well, due to memory usage.

For those working with PHP, mpm_prefork is the only safe way to work with the mod_php interpreter module. Despite the drawbacks, this will be the MPM a WordPress developer will choose if they have to deploy to an Apache server.

You will also see mpm_worker and mpm_event modules too. These perform a similar operation and scale better due to the way they can spawn multiple processes per collection of threads.

This batch of MPMs shows how flexible Apache can be, despite the drawbacks for performance in some cases.

Request handling for static vs dynamic content

Before we move on, we should mention static versus dynamic content for each server software. You’ll read that Nginx can’t process dynamic content, which might give you cause for concern. In fact, Nginx won’t process this type of content in a native way. Instead, it will send it out to an external processor (such as a cache), then wait for it to return before it moves the content on.

For development, a sysadmin will set up a solution such as Memcached for this. There are negatives to this approach, namely on performance. However, the benefits to the performance overheads for each portion of the chain negates this. Nginx doesn’t have to worry about processing these requests, so it can concentrate on its areas of responsibility with greater efficiency.

Apache’s MPM system lets it process both static and dynamic content without the need for other modules. For dynamic content, Apache embeds a language processor into each worker. It’s a simple approach that works well. You can also swap out modules if you need to make a change.

2. Configuring the server

One of the more apparent differences between Nginx vs Apache is how you configure each server. Nginx uses a centralized approach, which means a user has no way to configure a server outside of one main file. While this seems like a negative, there are lots of advantages:

  • The server administrator is responsible for global security, which tightens up access to the server as a whole.
  • A centralized server has greater performance than other types. This is because Nginx won’t need to handle requests to check for configuration files in each directory.
  • There’s a knock-on effect here, as there won’t be any overrides for the server from multiple areas, further keeping request times down.

One way that a layperson will know they use an Apache server is the presence of .htaccess files. These are configuration files that you can add almost anywhere on your server. Apache will check each element of a path for a .htaccess file when a request is made.

A .htaccess file showing some rewrite rules - Nginx vs Apache comparison

This is fantastic for users who want to personalize their portion of server but could spell disaster if one of the directives causes performance or security issues. This decentralized approach is one of the reasons you’ll see Apache used on shared hosting. It’s also a reason why a content management system (CMS) such as WordPress offers good performance on Apache servers.

3. Request interpretation

One major difference of Nginx vs Apache that won’t seem apparent is how it interprets requests. In a nutshell:

  • Nginx interprets and maps requests using a Uniform Resource Identifier (URI) for each component.
  • Apache can also use URIs to interpret requests, but it’s more common to see a file-based path structure.

Because Apache is a web server first and foremost, it will use <Directory>, <Files>, or <Location> blocks to define resources. The key concept here is that everything Apache ‘sees’ is related to the web server, so there is no ambiguity within the resource path. Think of a document tree, and this is how Apache ‘visualizes’ the server filesystem.

An Apache configuration file, showing filesystem protection for specific directories - Nginx vs Apache comparison

In contrast, Nginx has lots of use cases, such as a load balancer, proxy server, and a web server. Because of this, requests need to come as a URI for Nginx to process them. For example, Nginx uses server and location blocks: the former interprets the requested host, and the latter matches the URI portions afterward. The whole request becomes a URI.

An Nginx configuration file - Nginx vs Apache comparison

On the whole, a URI is more flexible for Nginx, because it can adapt to whatever function it carries out. Even so, Apache’s system works, given that it only has to fulfill the role as a web server.

Nginx vs Apache: Which one you should choose for your server in 2021

The catch-all answer to, Which server software should I choose? is simple: It’s whichever one your hosting provider offers. In lots of cases, you won’t get a choice. We notice that lots of web hosts follow the same pattern you should match if you want to decide between Nginx vs Apache:

  • If you want to run a server that needs constant configuration, or you want to give users a configuration choice, Apache will fit the bill.
  • However, if you want to provide super performance, rock-solid security, and want to handle configurations rather than your users, Nginx is the way forward.

When it comes to performance, Apache can take up more memory because of its inherent architecture. Nginx is going to be better in high-traffic situations, especially if it has to handle lots of static content.

Therefore, if you rely on caching to store and serve content, Nginx could be the best option. However, remember that Nginx can’t serve dynamic content, so you’ll take more of a performance hit depending on the efficiency of the proxy your server uses.


There are lots of areas of WordPress (and running a website) that offer an almost overwhelming number of choices. This is the nature of the beast. However, it doesn’t help when you need to make your site live quickly.

Your choice of server type is one crucial and frontline decision that you’ll want to take extra care over. Nginx vs Apache is a common comparison because both offer benefits in certain situations.

Our opinion is that Nginx can cover the most bases with greater performance, which makes it the better option for most WordPress users. This is why many of the popular performance-focused WordPress hosts have moved towards an all-Nginx server stack, including Kinsta and Flywheel.

Regardless, you’re safe to use whatever your host offers if you don’t get that choice and most WordPress sites will be totally fine with either web server.

Where do you sit on the fence between Nginx vs Apache? Let us know in the comments section below!

Free guide

5 Essential Tips to Speed Up
Your WordPress Site

Reduce your loading time by even 50-80%
just by following simple tips.

One thought on “Which Is the Best Web Server? (2021)

Leave a Reply

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