Contact
Site: US UK AU |
Nexcess Blog

Four Ways We Make Your Magento Store Faster

May 6, 2019 0 Comments RSS Feed

Four Ways We Make Your Magento Store FasterMagento is still one of the best eCommerce platforms available for merchants looking to optimize the eCommerce experience. Between incredible functionality and unrivaled product management, it provides the ability to create storefronts that can’t be created in other, comparable applications.

In 2018, we found that the top reason merchants chose Magento was functionality. Yet great functionality requires a lot of server resources. As a result, Magento is a known resource hog.

Luckily, with over 10 years of experience supporting Magento stores, we understand the application’s complex performance requirements. In fact, we even wrote the book on the subject. For this reason, merchants continue to choose Nexcess for reliability, security, and performance.

Interested in learning more about how we create Magento environments you can’t find anywhere else? This article looks at four of our optimizations and how they make your store faster with Nexcess.

  Get started with optimized Magento hosting.

PHP-FPM

PHP code lies at the foundation of Magento, and there are multiple ways that a web server can be configured to execute that code. Even minor changes to default configurations can lead to significant Magento performance improvements.

Usually, when you install PHP support on a web server, an apache module called mod_php is set up. This module offers a simple set of configurations that will provide a Magento installation with the type of performance you’ll see with any web host.

We don’t accept the default mod_php file configurations. Instead, we use PHP FastCGI Process Manager, commonly known as php-fpm, on our servers.

PHP-FPM allows Magento sites to make use of memory and CPU resources more efficiently than its mod_php counterpart. This helps Magento sites to better manage content and serve websites faster.

Usually, a mod_php setup is configured so that each Apache httpd process also contains a copy of the PHP interpreter. This inevitably means a larger memory footprint – even for Apache threads serving requests for static assets.

Under our configuration, there are separate PHP processes to serve dynamic requests, so the web server can serve only requests for static assets. This also allows us to tune settings related to how these processes behave to improve responsiveness or reduce memory footprint.

A Fine-Tuned OPcache

PHP is an interpreted programming language. This means that when PHP code is executed it must be parsed by an interpreter. This interpreter organizes the code into an internal representation that can then be executed by the PHP runtime.

Parsing must take place within the interpreter before the code can even begin to run. Usually, parsing repeats every time a request is made. That means that every time someone visits a new page on your site, the parser kicks in.

This is where OPcache can help. OPcache helps by saving the internal representation of the code so it doesn’t need to be parsed for each request. For an application like Magento, which has tens of thousands of PHP files, this translates into a significant performance improvement.

As part of our strategy for optimizing performance for Magento, we’ve tuned the settings for OPcache to support a large number of compiled files. This translates to less time spent parsing PHP code and more time spent running useful code that helps customers access your Magento store.

NGINX-Based Cloud Accelerator

One of the biggest resource demands on any eCommerce store is the delivery of static assets such as images, CSS, and JavaScript. On default Magento configurations, these assets are delivered through Apache after reading the file on disk.

By implementing built in microcaching using NGINX, static assets can be stored and served directly from memory for a short period of time. This is particularly useful for highly trafficked stores that have a selection of very popular products, with NGINX meaning that each visitor page load is faster and uses less server resources.

Nginx also provides HTTP/2 protocol support, which allows for optimizations such as server push, where a web server or web application can tell a browser to download additional assets in response to a request.

Traditionally a browser would not start downloading additional assets until it encountered them during a page load. Server push means a browser can be told to download static and other assets immediately.

In addition to these optimizations, we also have compression enabled automatically for relevant assets. This means that instead of serving a raw JavaScript, css, or other test file, we transparently and automatically compress the file so the download becomes smaller. This results in a significantly faster overall page download time.

As an example, the latest version of jQuery, a popular javascript library, is 86 Kilobytes in an uncompressed state. Compressing this with gzip yields a 30 Kilobytes file, or savings of over 65%.

Automatic Processing Priority

All multi-tasking operating systems have a mechanism called a CPU scheduler. This component determines which tasks are allowed to use the CPU at a given time and to what extent. On Linux, this is done by assigning a “niceness” value to a process. The value is called this because it determines how “nice” the process is, or how big a share of CPU resources that process will get. The idea is that nicer processes use less CPU resources.

Nexcess has created a system that automatically changes the niceness value of running processes so that web critical processes (NGINX, apache httpd, php, mysql, etc) get CPU priority over less critical tasks. (compressing files, backups, etc).

Additionally, we run most maintenance tasks with a low CPU priority. This helps ensure that your website responds quickly even when administrative or scheduled tasks are running.

Get Started With Optimized Magento

Magento optimization starts on the server and finishes in the application. Server optimizations can help to provide merchants with a solid foundation for creating the Magento experience they want, but the development process is still vital.

We always recommend testing new code and implementations on a dev site before you push to your production site. Dev sites allow Magento merchants and developers to test speed and performance in a secure environment.

Interested in learning more about how we help merchants to optimize the eCommerce experience? Visit our Magento hosting page to see what features come with a Magento install.

Posted in: Magento