Why shouldn't you use Nginx for Magento?

Why shouldn't you use Nginx for Magento? pixelwork

Why shouldn't you use Nginx for Magento?

Let's give you an analogy – a fast food restaurant (Magento).

The cast

The customer (in the drive-through) is the customer in your web store. The cook (who sits in a chair and hands you the bag of food through the window – Web Server) The cook (who prepares the meals – PHP) The sub cook (who prepares the ingredients for the meals – sub system server).

The challenge

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

Now, let's take Apache's perception (an overweight, unwelcome attendant at the window), the kitchen takes 14 minutes to make the food, deliver it to him – then he passes it to you. He is only passing 1 bag, every 14 minutes, a pretty easy job.

Let's improve performance

We want the business to run faster – so we'll fire Apache and replace it with Nginx.

The kitchen takes 14 minutes to prepare a meal and Nginx delivers the food bag at a lighter pace.

But wait, it still took 14 minutes for the customer to get their food – even though we have the fastest delivery staff available.

That's because it was never the person who delivered your food that was the bottleneck; In fact – the “slow” person had added value since she spoke the native language of the kitchen staff and could easily request orders (.htaccess support). While Ngnix speaks Russian and requires a translator to stop their work and tell them new commands (edit Nginx config, reload etc.).

The conclusion

Nginx will not improve the performance of Apache for Magento, it has been proven repeatedly in benchmark tests and the reason is that PHP (the chef) is the bottleneck.

Nginx/Apache are the front men – and in the case of Magento, they are nothing more than marketing tools. It's easy to show how fast Nginx/Lighttpd/Litespeed is 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 beat this relatively easily – hitting around 16k requests per second – but this is for static content. When you start hitting 12 thousand requests per second – then it's time to consider downloading Apache, but until then, it will perform par-for-par with anything else.

Our advice

If you are building a CDN, Nginx is a great option. If you want a static file proxy, Nginx is a great option.

If you want a flexible, high-performance web server for Magento, Apache is as good an option as Nginx, since at the end of the day, PHP (the chef) is holding you back, not the web server, never the web server.