Web Hosting

NGINX vs. Apache: A 2018 Comparison

A comparison of Apache & NGINX's features, performance, security, flexibility, and support.


NGINX and Apache are both open source web servers that cater for over 50% of all websites worldwide. NGINX is used by 39.4% of websites and Apache powers sites such as PayPal.com and Apple.com.

Both solutions are ideal for high traffic websites, and have many similar qualities. However, we’re here to discuss their differences and provide the long awaited answer to the question of NGINX vs Apache – which is best?

NGINX overview

NGINX was created to solve the C10K problem. This was to allow web servers to handle 10,000 concurrent connections. NGINX is set up to run one process per CPU to ensure maximum efficiency.

nginx

NGINX’s features include:

  • A load balancer
  • HTTP cache
  • Reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP
  • Front end proxy for Apache and other web servers

NGINX is commonly used by those who want static content quickly. Administrators are often popular users due to NGINX’s efficiency and responsiveness, as well as it’s light-weight nature.

Apache overview

Apache is the web server part for LAMP (Linux, Apache, MySQL, PHP) stack. Although other stack components do exist, LAMP is by far the most popular. There are around 60 official Apache modules that can be installed.

server map

Apache’s multi-processing modules (MPMs) can be split out into 3 main MPMs. You can view Apache’s full documentation on this area here.

Apache multi-processing modules:

  • Processes – Not brilliant with multiple concurrent connections due to the consumption of RAM used. High loads may cause the refusal of connections which can effect large sites.
  • Workers – This acts as a main single control process which is responsible for child processes. Child processes create fixed numbers of threads and a listener thread. Listener threads listen for connections in order to pass them to processing. This is a more scalable method that can deal with higher traffic sites, but can run into issues with very high traffic.
  • Events – Similar to the worker model above, the event model creates a listener thread which listen for connections in order to pass them to a worker thread. This creates much more efficiency. Apache 2.4 considers the event model to be stable enough to be the default setting.

NGINX vs Apache: Performance

Static content – When comparing NGINX to Apache 2.4 with the event MPM, running 1,000 concurrent connections, results showed NGINX to run 2.5 times faster than Apache. In terms of static content, NGINX is the clear choice for speed and efficiency.

Speedemy also ran this with 512 concurrent connections and found NGINX to consistently be twice as fast.

apache vs nginx

Dynamic content – If you’ve got a dynamic website using WordPress, Joomla, Drupal, etc. you may want to consider NGINX or Apache. Serving static content in these scenarios is very low when compared to dynamic content.

Again, we looked at Speedemy’s benchmark tests and the results were exactly the same. There was no superiority from NGINX in this instance. Why? Most of the requests are processing in the PHP runtime environment which is pretty much the same for both web servers.

apache vs nginx

NGINX vs Apache: Operating Systems

linux windows

This is a pretty clear cut test in the fact that there’s not much to test. Apache can run on Linux, BSD, etc. as well as having full support for Windows.

NGINX similarly runs on Unix-like systems but has limited support for Windows. When you look at NGINX’s performance on Windows versus other platforms, it’s nowhere near as strong.

NGINX vs Apache: Support & Documentation

Support, in my mind, is key when looking at any type of server. Apache have a great level of community support via mailing lists, IRC and Stack Overflow. There’s also the option for third party support from the likes of OpenLogic.

Similarly, NGINX also has support via mailing lists, IRC and Stack Overflow. NGINX also have a product called NGINX+ which has it’s own support covering more features.

features

Both NGINX and Apache provide top-notch documentation, covering almost every topic and feature you could think of. This documentation includes release notes, user guides, tutorials, and more. NGINX even have their own wiki!

NGINX vs Apache: Security

Both NGINX and Apache have a great track record in terms of security. Apache openly share their security updates and historical releases in their security reports. They also outline any known security vulnerabilities identified as part of Apache 2.4.

Similarly, NGINX publish any security advisories, as well as inviting users to raise security issues should they encounter any.

Apache and NGINX provider all users with security tips, such as how to deal with DDoS attacks and how to mitigate these. It’s safe to say that both web servers are hot on security and don’t shy away from any responsibility.

NGINX vs Apache: Flexibility

We’re in 2018, users want to take control and make customisations to their favourite web servers. So, can NGINX and Apache cater for this?

Apache has had the dynamic module loading ability for quite some time now, meaning all Apache modules support this. However, NGINX only received support for dynamic module loading at the start of 2016. Prior to this, admins were required to compile the modules themselves.

On the flip side, both NGINX and Apache have continuously growing feature modules:

ApacheOfficial modules and Wikipedia modules list

NGINXOfficial modules and third-party modules list

If we had to decide on one over the other, I’d probably go for NGINX purely on the basis that it can act as a reverse proxy, and the features included in NGINX+.

NGINX vs Apache: Conclusion

In terms of a comparison, both NGINX and Apache are strong contenders in different areas. NGINX is the clear winner for static content, whereas dynamic content produces no real difference between the web servers.

Apache may tip the scales when it comes to flexibility, particularly for shared hosting users. Apache’s .htaccess file and dynamic modules would most definitely be suited for this area, whereas NGINX is probably better directed towards VPS and dedicated hosting.

It really is just a case of weighing up which web server works for your needs. Either way, you’ll need a Linux hosting provider to get started, so head on over to our reviews section to find out more!


View Comments
There are currently no comments.