Groove Commerce
Developer's Toolbox: Need To Speed Up Your High-Traffic Magento Site? Start Your Nginx!

Traditionally, discussions about performance eCommerce optimizations are about code refactoring, database design, and other application-specific tweaks. However, evaluating your infrastructure from one level higher can be as equally important in the ability to serve your customers.

One of the key pieces of your overall environment is your web server – the software that handles the connection from a visitor and passes it along to the Magento design platform. You may already be familiar with two of the biggest names: IIS and Apache. Because Apache is installed by default in most Linux-based installs, it’s also used as the default choice in running much of the web’s content.

But many of Apache’s strengths – its robust feature set, with the flexibility to use it with nearly every web-based technology – are also its biggest weaknesses; all of those features, while nice, can contribute to what’s known as software “bloat”. The desire for faster and more streamlined services has made way for other choices that may help increase your user’s experience.

Nginx (pronounced “Engine-X”) is one such platform rising in popularity. Its goal is to provide the highest concurrency (number of simultaneous connections/users) with the lowest resource footprint (CPU and Memory usage). Simply put, it can help you serve pages to more customers in relatively less time.

One way Nginx achieves this is by doing as little as possible. By that, I mean the webserver is there to simply handle the request. The bulk of the work is passed off directly to a pool of waiting PHP processes (if you‘ve configured PHP with the built-in “FPM” module), which ends up reducing a lot of overhead. Less webserver overhead means more resources available to PHP, which is where 80% of the work needed to power your Magento design comes from.

Of course, where there are benefits, there are drawbacks. Or really, just one perceived ‘drawback’ – Nginx doesn’t support Apache-style .htaccess control files. The reasoning is simple enough: having to check for and parse the overrides gives a relative hit in performance. By pre-defining your rewrites in the webserver configuration files, Nginx can know immediately how to handle the request.

What does all of this have to do with Magento development? While it’s certainly not Magento-specific, it still directly affects what you’re trying to do – provide a fast, stable storefront in which to serve your customers. Many benchmarks have consistently put Nginx ahead of Apache in terms of performance and scalability. Even Magento's website utilizes it. By approaching your infrastructure from all sides, you give yourself a greater chance for success in the eCommerce solutions marketplace.

To learn more about Magento design & development check out the rest of our Developer Toolbox blogs.