It is not easy to select the eCommerce platform that best suits the needs of your online business. Even after you do, it’s always a challenge to keep it in shape. This is why you need the right resources to manage an eCommerce platform like Magento, especially if you want it to deliver optimum performance.

In case your store is slow or is due for maintenance, we’d suggest that you read our article on how to speed up and optimize your Magento website.

What are the leading platforms in the eCommerce world?

Suppose you are defining your organization’s business architecture and need an electronic commerce solution. In that case, one of the first questions we ask ourselves is: How many quality open source solutions in the world can provide online merchants with a flexible shopping cart system, and also control over the functionality, look and feel, and content of their ecommerce site?

A lot of names don’t come to mind when we answer this question but what does is Magento. Magento has become the best open source solution in the eCommerce world for large projects, and yet it can become our worst nightmare if we’re not careful. Its considerable weight is one of its weaknesses that could lead to a loss of visitors and money, especially if the platform’s elements are not installed or optimized correctly.

How to choose the Magento version that best suits your needs?

The obligatory payment of the subscription fee in the Magento Enterprise edition can turn into a quick return on investment because of its improvements in modules and functions (for example, customer segmentation with specific offers, call center software, etc.) They imply more significant optimization of the store, usability, user experience, and, in short, an increase in the sales conversion rate, which, in the end, translates into more revenue. Performance and safety factors are also key when making such a decision.

In any case, remember that Magento is complex and heavy, difficult to learn because it requires specific profiles, and any customization in the Community version (which may already exist in the Enterprise version) will have a high cost.

Global brands such as Nestle Nespresso, Nike, Olympus, Lenovo, Ford, and Samsung use Magento USA.

What aspects of optimization are critical with Magento?

Magento is a booming eCommerce platform that, regardless of its version, suffers when you don’t perform configuration optimization at its infrastructure level. By performing a multi-level cached installation, it is possible to decrease the response time up to 75% over the time of a standard Magento installation.

If we want to have a good online store, the response speed and page load must be less than 2 seconds, and most importantly, the response time of the first byte (TTFB) should be less than 200 ms.

The 8 main optimization components in a Magento infrastructure are described below:

  1. Apache Web Server in version 2.x, hereinafter Apache.
  2. PHP module version 5.5 or higher with the required extensions and PHP Zend Opcache accelerator.
  3. Magento EE 1.14.1 or Magento CE 1.9.1 with a post-installation optimization process.
  4. GNU / Linux x86-64 operating system (64-bit version).
  5. Databases MySQL in version 5.6.
  6. Memcached distributed cache system.
  7. Reverse proxy with Nginx web server.
  8. Varnish as a reverse HTTP proxy cache.

Apache optimization

Apache needs some specific configuration parameters for the correct operation of Magento. Link rewriting must be configured (with the mod_rewrite module) to get friendly URLs and speed up searches on the Magento platform.

For optimization, the most important thing is to correctly configure persistent connections (with the KeepAlive option and header module) depending on the size of memory you have, allowing you to reuse connections with requests concurrently. In addition, file compression (with deflate module) is necessary, since Magento generates a high volume of data.

Similarly, using a cache strategy at the web browser level (with mod_expires module) is essential so that the first access to the online store downloads all static resources (js, CSS, images, etc.) and stores them in the browser, avoiding making unnecessary requests.

You will also have to use and configure the Apache Prefork worker MPM to manage the processes that will be able to open the number of requests that it will be able to respond, and therefore, the amount of resources that it will be able to consume.

As with the rest of the infrastructure components, we will deactivate the logs to reduce reads and writes to disk.

Optimization with a PHP accelerator

The goal of a PHP accelerator is to cache compiled PHP scripts in bytecode to avoid the overhead of parsing and compiling the source code on each request.

Following performance tests on Magento using other PHP accelerators such as Xcache and APC, we see that the PHP Zend Opcache accelerator achieves better results and has been integrated into the PHP module since its version 5.5 (Opcache module). It is necessary to adjust the PHP accelerator’s configuration parameters, which must be adjusted by defining the memory consumption, the number of files to be cached, etc.

Magento optimization

The default Magento installation requires further customization to improve its performance. Some of these options are:

  • Activation of the cache. Magento integrates a cache system to serve files more quickly.
  • Unification of JavaScript and CSS files. Magento has a number of JavaScript and CSS files (more than 40), which you will have to compress to function.
  • Compact Database. Magento creates a database where the information of the products and the categories is dispersed in many tables. This causes the reads and writes of these to be slow since it must join that disaggregated information.
  • Disable Magento logs, avoiding disk writes.

Optimization from GNU / Linux (RAM Disk creation)

To considerably improve the use of the Magento cache, which uses a directory in the filesystem as persistence, we recommend mounting the cache directory on a RAM Disk, on the GNU / Linux system, so that the reads are faster.

MySQL optimization

Although there are other better-regarded database servers on the market, MySQL (with the InnoDB storage engine) has shown good performance when it comes to serving light but constant and concurrent requests.

Some aspects of optimization are:

  • Increasing the number of maximum connections, since we have enough resources on our server.
  • Activating the query cache.
  • Increasing the memory that the query cache will use.
  • The memory that each query can occupy in the said cache (the relation with the cache’s size must be maintained).
  • Maximum number of tables that will be kept in the cache to be consulted.
  • How many threads will be cached for use in new connections.
  • Disable logs for slow queries and error logs once they have been analyzed.

Optimization with Memcached

Memcached is a general-purpose distributed system for the cache. We can define a memory pool, which can be on another server, where the operations performed by Magento and the session variables are stored.

Optimizing with Nginx as a reverse proxy

Nginx is an alternative engine to Apache. We recommend that you configure it with Magento since not only is it better than Apache, but it also serves static content (images, documents, etc.) and compresses the contents faster than Apache. Therefore, Nginx will act as a reverse proxy for Apache, serving static content, and passing dynamic page requests to Apache.

It is recommended to configure Nginx in this way or to use a CDN such as Amazon CloudFront or CloudFlare.

Integrating CloudFront or CloudFlare with the Amazon S3 solution can be a good option since the number of requests processed by the Apache server is reduced, so that the static content would be balanced with Amazon S3 and, if we also create subdomains for it, we can make it send without cookies. An important tip is to utilize file compression to reduce the volume of traffic generated for each request and deactivate the log level from an optimization point of view. It is impossible to take full advantage of Nginx due to Magento’s internal workings, which generates HTML documents dynamically, with few exceptions. As a result, Nginx cannot handle serving such documents as often as would be desirable.

Optimization with Varnish

Varnish will try to serve clients’ requests from the cache, which we will establish in volatile memory, instead of on the hard disk, occupying the defined maximum memory. Keep in mind that Varnish does not serve content that contains cookies because it can carry sensitive information. Magento is an eCommerce platform that makes use of cookies, so Varnish will not be able to serve those contents that make use of them. With the optimizations recommended in this article, you can significantly reduce your Magento website’s loading time while improving your user’s experience.

Conclusions

Keeping your Magento site up to speed might seem like a daunting task, but it’s not impossible. You just have to make sure that you take some precautions and be careful about a couple of pointers: optimizing for speed should start from well-developed code, a good template, and an ad hoc configured and optimized server.