Magento Performance | Optimize your website performance
Cant the customer wait longer?
Simply put, no. Every 100ms that you lose in your webshop loading time, is causing a lot of your customers to bail out. Impatience, authenticity and sometimes they just dont feel like they want to be associated with those waiting times. These are all reasons for your customer to find its business elsewhere and make you lose precious revenue on a daily basis. With just a few simple tricks, you can boost your Magento Performance, and with that your Sales, drastically.
To make a car perform, you need to make sure it has an engine to do so. This goes for Magento aswell. If you want it to perform, the servers need to be able to deal with the load thats incoming. Disk Input/Output, Network speed, CPU speed, CPU cores, memory size, memory speed. All of these count when it comes down to getting the Magento Hosting worked out. Atop of the hardware, the services which are connected to Magento are extremely important
Tuning a server makes no sense if you cannot measure performance in any point of time. You need to be able to see what happened to be able to improve the performance. Issues in performance dont usually surface right away but they are most of the times following an repetative pattern for that specific server. So measuring is the only way to see what happens and adapt as you go
You can use tools like New Relic Infrastructure, Puppet or Zabbix to measure the performance of your server and get historical data which helps you to constantly improve it.
Choosing the right services
Magento by itself is very resource intensive. To be able to deal with this resource requirement, its important to have all services on your server properly setup. Setting these resources up is usually a tailormade solution due to the bottlenecks caused by hardware. One bottleneck caused by for example memory occupation can cause all services to under perform. Ensuring the right services are setup with the proper settings is the only way to really achieve proper performance under heavy load.
What services are we talking about?
There's ofcourse many services which can be used in conjunction with Magento 2 and it's usually best to connect each of them. We'll get into detail about their roll in the setup in the following sections. This includes: Nginx, PHP-FPM, MariaDB, Redis, RabbitMQ, ElasticSearch, Varnish
Nginx vs Apache
There's multiple choices to go for and if you read the internet, of which we are pretty sure you do, you may already have found out that benchmarks about using Nginx or Apache are stating that with proper setups, the differences arent all that large. Thats 100% correct and this is empowered by the fact that the webserver itself is rarely a bottleneck for your Magento 2 webshop during high load
We suggest Nginx over Apache for the simple reason that Nginx performs much faster in a default setup and with minimal tuning, can be setup to perform extremely well. The setup is easy, Magento 2 even included sample configurations and there's a lot of optimization manuals online to tune Nginx.
Sessions in Magento are usually stored on the filesystem which is causing a lot of disk i/o actions upon creating new sessions and reading existing sessions.
When a session directory is flooded with thousands of session files, this adds another problem being directory scan i/o performance which adds even more loading time.
One very solid solution to this is by moving the Magento Sessions to a Redis Server. this works very easy, fast, the setup is only a little bit of configuration and adds a tremendous amount of speed to the website
PHP isnt the most efficient scripting language in the world. It gets a lot better every version but as Magento 2 rely fully on PHP as its interpreter, its very important to set this up for success.
FPM means Fast Proxy Mode and allows your server to start php processes which will remain running and serve a combination of multiple php interpret calls, saving a lot of php startup time and increasing the speed of your frontend drastically. This is one of the largest performance gains a website get with the least amount of effort
MariaDB or PerconaDB
In a Magento 2 setup, the way the database is generated and used limits the server maintainers ability to make the performance of SQL queries a lot faster. It's not as easy as in a "fresh" application to setup and optimize each table, as Magento itself maintains the table structure for most of the tables aswell as extension maintainers probably maintain their own tables via their extensions
Choosing a performance oriented database like MariaDB or PerconaDB will increase the speed of the tables (which use either a MyISAM or InnoDB engine for Magento 2) drastically. Its as easy as installing a regular MySQL server and supports the exact same query structure so they can be switched easily. A little bit of tuning with a performance guide specifically for MySQL and your webshop will have significantly less startup time
AMQP using RabbitMQ
Magento relies on a continuous execution via time based patterns. This is called a cron timetable which executes according to a schedule. These executions cause Magento to be started up and all the scheduled tasks to be run, including reindexing of products, sending of mails, generating reports and other housekeeping actions which can consume a lot of resources
By default, Magento runs its cron and generates blocking processes on the server, which causes noticable and significant performance degradation overtime. Setting up RabbitMQ to process your cron queues will offload the execution of tasks from Magento to separate processes, reducing peak load on your server at scheduled times by a very great amount.
AMQP stands for Advanced Message Queuing Protocol , it basically ensures to execute tasks in a controlled manner aslong as they are not relying on eachother to be finished. Every task is an invididual task
All pages in Magento 2 cause the database to be called and queries to be run on its extensive database schema. Magento uses a system called EAV (Extensible Attribute Values) which provides a lot of dynamics yet huge pitfalls as websites grow slowly out of proportion. As a website gets larger and larger, queries to MySQL are taking longer to complete as more data needs to be returned
Connecting Magento 2 to ElasticSearch takes a way a very big deal of this stress. Indexes of your products and categories are no longer persisted to MySQL but are fetched from ElasticSearch which is extremely faster and causes only a fraction of load. This index is then used in search results and on category pages, filters and even product detail pages.
Not only does this provide a substantial performance increase, it also provides the ability to order and filter your data smarter and showing information to your customers which matters them the most
Varnish Full Page Caching with ESI
Varnish provides a way to cache a full page in memory, reducing initial page load times by a great deal. It can reduce loading time for a regular Magento page to around 15MS per pageload which is about 500MS faster than without!
Magento supports a mechanism called ESI hole punching, which allows a fetched page from Varnish cache to be provisioned with dynamic data, making it useful in situations where you require things like customer data dynamically rendered on every page
There is nothing faster than serving content even before it reaches your server. There's many external services which you can use to increase the performance of your Magento 2 installation, but the one we really suggest is CloudFlare.
This service provides a service which allows you to render static cached content directly served by cloudflare, causing no load on the server and rendering each static file in only one or 2MS. This method is called "Network Level Caching" and there's no faster way nor is there anything which reduces load. Simply put, if the request never makes it to your server, there's no load imposed on the server what so ever
Other Magento shortcomings
Ofcourse there are other shortcomings in Magento, but having the top 3 issues worked out, is usually setting you in the right direction.
Having a lot of bundle products in your shop can cause your magento performance to drop siginificantly. One reason for this is that it makes a lot of extra relations and has to load them every time.
Our Configurable Bundle extension resolves the performance issue by allowing you to connect one configurable product to an option instead of a ton of simple products.
Got performance issues?
Check our services below or get into contact with us via either the contact form or our chat below. We will get in touch with you and talk about the causes of your Magento Performance issues and how we would deal with them. You'd be surprised how easily and for a low cost, we would be able to help you out in getting your shop to perform optimally and converse better.