Why shouldn't I use Nginx for Magento

Nginx vs Apache for Magento

We are going to give you a loose analogy – a (Magento) fast-food restaurant.

The cast

The customer (at the drive-through), is the customer on your web store. The till operator (who sits on a chair and hands you the bag of food through the window – Web Server) The chef (who cooks the meals – PHP) The su-chef (who prepares the ingredients for the meals – server subsystem)

The Challenge

The average meal takes 2 minutes to prepare, 12 minutes to cook and 5 seconds to hand to the customer.

Now, lets take the perception of Apache (an overweight, unfit, slow window attendant), the kitchen takes 14 minutes to make the meal, hands it to him – then he passes it to you. He is only passing 1 bag, every 14 minutes, a pretty easy job.

So lets improve performance

We want the business to run faster – so we’ll fire Apache and replace him with Nginx (the Ivan Drago of fast-food service).

The kitchen takes 14 minutes to prepare a meal and Nginx hands the bag of food at lightening pace to you.

But hold on, it has still taken 14 minutes for the customer to get their meal – even though we’ve got the fastest delivery staff available.

That’s because it was never the person handing you the food that was the bottleneck; in-fact – the “slow” person added value by speaking the native language of kitchen staff and being able to receive updates (.htaccess support). Whereas Ivan speaks russian and it requires a translator to stop him working and tell him new updates (edit Nginx config, reload etc. yada yada yada).

The conclusion

Nginx won’t improve performance over Apache for Magento, we have proved in time and time again in benchmark testing and the reason is because PHP (the chef) is the bottleneck.

Nginx/Apache are the front men – and in the case of Magento hosting are no more than marketing tools. It is easy to show how fast Nginx/Lighttpd/Litespeed are over Apache in terms of reqs/s.

On a given server (2.5GHz QC/8GB RAM), Apache is good for around 12k requests per second, Nginx can surpass this with relative ease – hitting around 16k requests per second – but this is for static content. When you start to hit 12 thousandPHP requests per second – then its time to consider dumping Apache, but until then, it will perform par-for-par with anything else.

Our advice

If you’re building a CDN, Nginx is a great choice If you want a static file proxy, Nginx is a great choice (heck, we use it ourselves).

If you want a flexible, high performance web server for Magento, Apache is just as good a choice as Nginx – as at the end of the day, PHP (the chef) is slowing you down, not the web server – never the webserver.