Nginx vs Apache: Which Serves You Best in 2019?

Featured Apache vs Nginx Design Credits: Vecteezy.com-226441

For two decades Apache held sway over the web server market which is shrinking by the day. Not only has Nginx caught up with the oldest kid on the block, but it is currently the toast of many high traffic websites. Apache users might disagree here. That is why one should not jump to conclusions about which web server is better. The truth is that both form the core of complete web stacks (LAMP and LEMP), and the final choice boils down to individual needs.

For instance, people running Drupal websites often call on Apache, whereas WordPress users seem to favor Nginx as much if not more. Accordingly, our goal is to help you understand your own requirements better rather than providing a one-size recommendation. Having said that, the following comparison between the two gives an accurate picture.

1. Popularity

Up until 2012 more than 65% of websites were based on Apache, a popularity due in no small measure to its historical legacy. It was among the first software that pioneered the growth of the World Wide Web. However, times have changed. 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. Between them they dominate nearly 85% of the web server market.

Web Servers Market Share W3techs.com

When it comes to websites with high traffic, the following graph is interesting. Of course, Nginx is quite ahead of Apache but trails behind Google Servers which powers websites like YouTube, Gmail and Drive.

Web Servers Market @ W3Techs 15-Jan-2019

At some point a large number of websites (including this site) migrated from Apache to Nginx. Clearly, the latter is seen as a the latest, and a trendier web server. High traffic websites that are on Apache, e.g. Wikipedia and New York Times, are often using a front-end HTTP proxy like Varnish.

Score: The popularity gap between Apache and Nginx is closing very fast. But, as Apache is still ahead in absolute numbers, we will consider this round a tie.

2. Speed

The main characteristic of a good web server is that it should run fast and easily respond to connections and traffic from anywhere. To measure the server speeds, we compared two popular travel websites based on Apache (Expedia.com) and Nginx (Booking.com). Using an online tool called Bitcatcha, the comparisons were made for multiple servers and measured against Google’s benchmark of 200 ms. Booking.com based on Nginx was rated “exceptionally quick.” In contrast, Expedia.com based on Apache was rated “above average and could be improved.”

Having used both travel websites so many times, I can personally vouch that Expedia feels slightly slower in returning results to my query than Booking does.

Web server response time Booking.com (Nginx) vs. Expedia.com (Apache)

Here are comparisons between the two servers for a few other websites. Nginx does feel faster in all cases below except one.

Website server speeds tested at Bitcatcha

Score: Nginx wins the speed round.

3. Security

Both Nginx and Apache take security very seriously on their websites. There is no dearth of robust systems to deal with DDoS attacks, malware and phishing. Both periodically release security reports and advisories which ensure that the security is strengthened at every level.

Score: We will consider this round a tie.

4. Concurrency

There is a perception that Apache somehow does not measure up to Nginx’s sheer scale and capability. After all, Nginx was originally designed to accelerate speed issues with FastCGI and SCGI handlers. However, from Apache 2.4 onwards (which is the default version), there has been a drastic improvement in the number of simultaneous connections. How far this improvement has been made is worth finding out.

Based on stress tests at Loadimpact.com, we again compared Booking.com (Nginx) with Expedia.com (Apache). 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. Clearly, if you have a dedicated high-traffic website, Nginx is a safer bet.

Scalability testing Apache versus Nginx at Loadimpact.com

Score: Nginx wins the concurrency round.

5. Flexibility

A web server should be flexible enough to allow customizations. Apache does it quite well using .htaccess tools, which Nginx does not support. It allows decentralization of administrator duties. Third party and second-level admins can be prevented from accessing the main server. Moreover, Apache supports more than 60 modules which makes it highly extensible. There is a reason Apache is more popular with shared hosting providers.

Flexible features of Apache: Modules plus htaccess example

Score: Apache wins this round.

Other Parameters

In the past Nginx did not support Windows OS very well, unlike Apache. That is no longer the case. Also, Apache was considered weak for load balancing and reverse proxy which has changed now.

Final Result

Nginx narrowly wins this contest 2-1. Having said this, an objective comparison between Nginx and Apache on technical parameters does not give the complete picture. In the end, our verdict is that both web servers are useful in their own ways.

While Apache should be used with a front-ending server (Nginx itself is one option), Nginx can be better with more customizations and flexibility.

8 comments

  1. Popularity is a suspect measure. After all, Windows is the “most popular” O/S. Is it because it is so much better than other O/Ss or is it because of vendor lock-in? Ubuntu is the most popular Linux distro. Is it that much better than other distros?

    1. Apples and oranges, Dragon. Web servers are a very different conversation topic. This market is effectively a duopoly. Except for Google servers addressing more high traffic websites than anything Nginx has to offer. Same with Facebook’s proprietary servers. These have the industrial strength of managing traffic for billions of users at the same time.

      For most others, if I have to set up my website on a server, I will have keen interest in knowing which one, Apache or Nginx, is being trusted by more website owners.

      Besides there is a lot of conflicting information all over the web on the exact numbers for both servers. Some say Nginx has already eclipsed Apache. Some say Apache is used by two-thirds of all websites. With these latest numbers, all doubts are put to rest. If fewer people are going to use Apache (which is not exactly true), then it could weigh in my decisions on should I replace it now.

      1. What conflicting information? Most of the reports, that I’ve seen, were saying, that NGiNX is faster, then Apache, while Apache is more flexible.

        1. True that. But, this section is about how commonly either Apache or Nginx are being used with websites. These figures are latest.

  2. Unless the only thing changed is the web server software, most comparisons are meaningless.

    These two websites have similar function, but use entirely different applications, on different hardware, with different internet access. The response speed of such a site is likely driven largely by the database access time rather than the http server.

    A better test would be to put the same application on both web servers, on the same physical server.

    1. Hi Scott

      Bitcatcha is specifically a server speed checker. This is what it says on the website:
      https://www.bitcatcha.com/blog/every-millisecond-counts-why-i-created-bitcatchas-server-speed-checker/

      “”I created Bitcatcha’s very own server speed checker for one simple reason.To show you how fast (or slow) your server is performing. Number 1 (your server speed and web host) is your engine. It’s how long – in milliseconds – it takes for your server to respond to a request.”

      Of course, there are other factors that govern server response including database access time. Only in one case, Nginx was slower than Apache (Sydney Morning Herald vs. CBS). In general, Nginx servers are faster than Apache.

      However your test suggestion is well-received.

      Thanks

  3. Thank can you explain how one may put another software ahead of Apache. For the example with Varnish is it better than Nginx?

    1. Hi Nihic

      Thank you for your query. Can only explain this in a new blog entry and only using very simple steps. Please wait for some time on this. Varnish is an accelerator which makes Apache very fast.

      Regards

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories