Using Nginx & Apache Together – A Secret Formula to Accelerate Magento Performance

by Mehdi KaramAli  November 20, 2016

The debate of choosing between Apache and Nginx is not new. For a Magento ecommerce store, we have seen customers asking us about the web server which can handle maximum requests in the minimum period. Webmasters are now well aware of the site speed as search engines and visitors both appreciate a website that takes a few seconds to load.

Nginx & Apache Together

With the holiday shopping season approaching, most ecommerce stores will have a considerable increase in their site traffic. Serving those big amounts of requests and that too without exhausting the resources will be a need for every ecommerce store. So, which web server is better for this purpose? Apache or Nginx? Or do system engineers recommend any third option?

In this post, we will examine both Nginx and Apache performance to ascertain the significance of using them — and what formula can we use to maximize the performance of clients’ stores.

Apache: Tested and Reliable

Even with competitors like IIS, Litespeed, and Nginx, Apache has a share of 65% in web server market. The LAMP stack (Linux, Apache, MySQL, and PHP) has been a complete web solution to developers for more than a decade.

Similarly, regarding features, there is no competition to Apache. .htaccess has been the most important reason Apache is still popular amongst the developers. Especially in Magento, having application control and configuration is definitely important for webmasters.

There are multiple reasons that provide an edge to Apache on Nginx, especially when it comes to Magento:

  1. .htaccess support: Configure and customize your application with ease.
  2. Very easy to configure. You can find enough resources for it online.
  3. Compatible with different app-specific modules.

Drawbacks:

Apache falls short when it comes to serving plenty of static files. However, the latest version of Apache has resolved this issue considerably.  Moreover, Apache, having a process-based mechanism, is definitely a heavy memory web server.

Nginx: Lightning Fast Alternative

Nginx came in quite late but was able to attract some big names in IT industry quickly. Netflix, Dropbox, SoundCloud, Pinterest, and Instagram are in its rapidly increasing consumer base. WordPress.com has found it to be the only load balancer that can respond to 8,000 live traffic requests per second.

While Apache is created to provide an all-in-one web server, Nginx aims towards performance and efficiency. With its event-based approach, it uses fewer resources, provides only the most necessary features, and responds in blazing speed.

Drawbacks:

Nginx can only be used with PHP-FPM, and that lacks support for .htaccess. This means a simple redirection can even be a technical issue. Moreover, while Nginx is undoubtedly fast in delivering static content, Apache still leads when it comes to PHP requests.

Verdict: The Best Web Server for Magento

Though we could have easily given the decision either for Apache or Nginx, things are a bit different in Magento. The ecommerce giant is resource hungry and requires a lot of CPU. On the other hand, memory consumption, which is usually the focal point in comparing Nginx and Apache performance, is never a severe issue.

Secondly, it is the PHP that actually slows things down. No matter how quick the web server delivers, the actual time is consumed by the PHP. As pointed by Magento developer at Sonassi, Benjamin Lessani, a comparison of both while using PHP-FPM proves that their performance is identical. His comparison between these two web servers is worth reading as he explains the same point as ours in a highly creative manner

So for giving a high performing Magento site, you need to look at the big picture and look for a web server that can deliver both static and PHP content with efficiency. And while performing multiple Apache Nginx benchmark test, we found the best solution as:

Nginx + Apache + Cloudways FPC

Is it necessary to choose between one of the web servers for your Magento? We, at Cloudways, believe otherwise. That is the reason why we use a comprehensive strategy using both Nginx and Apache while keeping Cloudways Full Page Cache with them.

In this strategy, Nginx quickly delivers static content that is stored in Cloudways FPC. This means Nginx responds at even faster speeds. On the other hand, Cloudways FPC can serve content in no time, thanks to its robust caching mechanism. It requires minimal resources and can serve more audience while lowering the load on your server.

In the case of a dynamic PHP request, it is sent to Apache which knows how to deliver it efficiently. This means that we can have the performance of Nginx and flexibility of Apache together while lowering their drawbacks to the maximum.

Convert visitors into buyers on your 100% faster Magento store.

Deploy your Magento stores on optimized Magento hosting servers.

 

About Mehdi KaramAli

Mehdi KaramAli worked as a Digital Content Producer for Cloudways. Apart from exploring new trends in the cloud, he keenly follows startups and is passionate about mountaineering.

Stay Connected:

You Might Also Like...