Magento is a powerful e-commerce platform offering everything you need to sell online. Besides the e-shop itself, it can manage stock, marketing, invoicing, and accounting. Currently, Magento comes in two versions: Magento Open Source (formerly Magento Community Edition) and Magento Commerce (for larger organisations with in-house developers).
Magento is one of the most-used e-commerce platforms and is consistently highly rated by users. However, in order to run Magento correctly it’s necessary to have a developer who is experienced with such applications as well as an experienced hosting provider who knows how to optimise servers for Magento.
The need for powerful hosting
As mentioned, it’s crucial not to underplay the importance of hosting when it comes to Magento. The platform is performance intensive and the hosting parameters must reflect that. Putting to one side the problems and errors within the application itself, the majority of problems with Magento are caused by a lack of power from the web server, or as the case may be, the environment where Magento is being run. Magento is slower and has a much higher volume of requests compared with other systems, but there are several ways to speed up the platform.
Speeding Magento up
Magento cannot usually run directly on the web server, but instead it’s necessary to use a caching proxy (currently only Varnish is supported).
If you wish to (as is standard these days) run a SSL version, it’s critical to put Nginx or another SSL terminator in front of the Varnish proxy. Regarding the web server itself, it’s possible to use Apache with a PHP module or Nginx with PHP-FPM. One of the most effective ways to speed up Magento is to use a PHP accelerator. For basic installations, APC is considered the best option.
There are therefore two possible solutions:
- NGINX → VARNISH → APACHE (PHP-MODULE + APC, Memcache, Redis) → MariaDB
- NGINX → VARNISH → NGINX (PHP-FPM + APC, Memcache, Redis) → MariaDB
For a larger installation, it is appropriate to use Redis for the cache and as a session handler. If you choose to run the whole installation on one server, it’s imperative to have powerful hardware or hosting which directly supports Magento. PHP, MySQL and Varnish will all compete for memory, CPU and IOPS.
Running Magento in a cluster
If you choose to run Magento in any kind of cluster mode (either because of power or high availability), Magento doesn’t account for this option by default. There are several ways to assemble the cluster:
- The more complicated way is to use Varnish as a load balancer on each backend but then it is necessary to properly deal with cache invalidation and with other similar problems.
- An easier way is to leave balancing to the Varnish cache, which is powerful enough on its own to be able to pass requests to several backends.
For cluster installations, it is also recommended to use a dedicated server for backend admin, for which, paradoxically, caching isn’t particularly desirable. For version 2 and below it is recommended that you enable the Magento Compilation function to speed up Magento storage.
Our experience shows that the most common instances of slowdown are a result of the following application errors:
44% SQL queries within a loop
25% loading the same model multiple times
14% using a redundant data file
10% calculating the field size at each loop iteration
7% inefficient memory usage
Conclusion: An experienced hosting provider and programmer will fine-tune how Magento runs
The advantages of Magento are that it is robust and universal. On the other hand, it is hard to ensure that it runs optimally. If you are considering using Magento for your e-shop, be sure that:
- Your programmer has experience with the Magento platform
- The hosting provider you choose knows how to fine-tune a server for Magento so that everything works perfectly without any loss of speed.