• Sales 0808 1686 777
  • Support 0333 0142 700

Apache vs NGINX

apache vs nginx

Apache and NGINX are both popular choices when it comes to web server software. Since the initial release of Apache in 1995, it’s become the most widely used web server worldwide, and with good reason. Apache is reliable, open-source and supported by an extensive community, and over the years it’s become an integral component of web service models such as the LAMP stack.

But in the past decade, a real alternative to Apache has emerged in the form of NGINX. Pronounced ‘engine-X’, this web server software was designed from the beginning as a replacement for Apache, with features to remedy performance issues experienced by Apache users.

Still, a comparison of Apache and NGINX reveals pros and cons for each – so if you need a web server on your dedicated box or cloud VM, which one should you go for?

What NGINX brings to the table

Like Apache, NGINX is an open-source solution, and comes with many similar features. But the philosophy behind NGINX is more focused on performance and scalability, and dealing with high traffic in particular.

While Apache can handle a large number of requests per second, its performance will often slow down as they increase, e.g. when website visits suddenly spike, page load times will suffer. NGINX is optimised to provide consistent and predictable performance, even under heavy load. This is due to the architecture of NGINX and how it differs from Apache.

Usually, Apache creates a new process for each new request. This is a simple model and works well for lower-traffic applications, but as numbers increase it can be extremely demanding on hardware resources and result in slower performance.

NGINX uses ‘asynchronous event-driven architecture’ – which essentially means it doesn’t need to spawn a new process for each request. Instead, each NGINX process can serve numerous requests, translating to a reduced impact on hardware and performance.

Ultimately, this event-based architecture means that NGINX can cope with around four times more requests per second. Apache can be configured to enhance its performance, but NGINX has a big advantage out of the box, making it a tempting choice for anyone running a site with high visitor numbers. Even so, Apache still has an edge over NGINX in other areas.

Where Apache still shines

One of the benefits of Apache is its sheer popularity and convenience. Simply by virtue of being the preferred web server for so long, the level of support, help resources and third-party add-ons available for Apache easily outclasses NGINX.

Most Linux servers come with Apache pre-installed, and if you’re already familiar with its ins and outs, chances are you’re more likely to stick with Apache rather than take the time and effort to learn NGINX. On the other hand, if you’re just starting out as a server admin, NGINX is relatively easy to pick up.

Apache also offers more flexibility than NGINX in certain respects, for example the .htaccess file that allows directory-level configuration – it’s supported by Apache, but not NGINX.

One of the downsides to the high performance of NGINX is that adding dynamic modules isn’t as simple. Apache allows internal modules to be loaded at start-up to handle a range of functionality like SSL or authentication to a Windows DC – but with NGINX, anything like that needs to be 'baked in' well in advance.

Another area where Apache can outperform NGINX is dynamic content. Apache comes with the built-in ability to parse and execute a wide variety of dynamic scripting languages including PHP, Python and Perl.

While NGINX may be able to serve up static website content very effectively under stress, its process for handling dynamic content is not as efficient. This means that if your site has a lot of dynamic features, you may prefer Apache for reasons of functionality and convenience.

Why not both?

If you’re having trouble choosing between Apache and NGINX, one option is to not choose at all. It’s perfectly viable to run Apache and NGINX alongside each other and get the benefits of both. NGINX can function as a frontend proxy server, meaning it can be placed in front of Apache to manage high numbers of concurrent requests. Apache still runs at the backend to handle dynamic content, giving you the best of both worlds on your server. Whichever web server software you choose – Apache, NGINX, or both – you’ll need a full range of server options to implement your preferred setup. At Fasthosts, our powerful dedicated servers and highly scalable CloudNX platform give you the reliability and flexibility you need to run your websites and applications at peak efficiency.

Neal Thoms's picture

Neal Thoms

Author As a content creator for Fasthosts, Neal’s main focus is cloud technology and how it’s transforming everything we do online. He’s worked in the web hosting industry for over five years.