Providing a good shopping experience for your customers is mandatory since, when it comes to online marketing, an online store can lose business faster than it can make it. Statistics show that it takes only 3 seconds for a user to decide to leave a website if it is not responsive and/or it loads too slowly. How can you optimize Magento performance?
“If an e-commerce site is making $100,000 per day, a 1 second page delay could potentially cost you $2.5 million in lost sales every year.” [Kissmetrics]
Ecommerce customers are not patient these days and the loading rate of a website is an important factor search engines take into consideration to decide the ranking of every web page.
Customers usually expect a web store’s page to load in 2 seconds max, and statistics show that after 3 seconds almost 50% of the users abandon a web page if it is not loading, and choose to go to a competitor.
Additionally, the performance of every website has a great impact on users experience and directly influences the conversion rate of every business, so making the necessary efforts to solve your performance issues is exactly what you need to do to make the best out of your Magento web store. Even a 1-second delay on a page response time can lead to a 7% decrease in conversion rates, according to a research made by Aberdeen.
Thus, it is highly advisable for every Magento owner to measure the store’s performance and to check the technical documentation we have prepared in this guide in order to solve loading speed related issues. You can also benefit from improved performance for your Magento store by installing performance-enhancing extensions to boost user experience and, ultimately, increase sales.
Measuring your Magento store performance
Testing your site’s performance
Before going any further to the Magento performance checklist we prepared for you below, take a quick test to find out how fast your Magento store is loading right now. It is useful to see how you managed to make your Magento site more responsive, based on the techniques you’ll learn about in this Magento performance guide.
To test your site you can either use simple straightforward online tools, or opt for more complex one, like the Magento Profiler.
When it comes to online tools, here are a few that we recommend in checking your site’s speed and overall optimization:
These online apps typically give you a score and a range of recommendations on where you can make improvements. While definitely good for a quick first check, they won’t be able to see beyond the frontend of your site. That means if your site is having performance issues, especially due to high loading times, these tools won’t show you exactly where the problem is.
This is why Magento comes built in with an internal Profiler, allowing you to delve deeper once you found out about the issue.
Troubleshooting performance issues using Magento Profiler
To identify your Magento performance issues you can use Magento Profiler to assist you in finding out which specific processes use too much of your resources, such as database queries generated by your customer’s activity on your Magento store.
Before you begin
Also, you will want to check if there are any database related issues that might slow down your website. To do this, login into MySQL and run “show processlist” to browse all the slow pages of your website. When a query stays on the screen for too long, you’ll know you have a database performance issue and you go ahead should solve this first, before going further to enabling Magento Profiler and see what other processes may cause your store to run slow.
Magento Profiler’s Purpose and Use
Magento comes with a handy solution to help your troubleshoot your Magento performance related issues and figure out precisely what processes overloads the activity on your website.
By activating Magento Profiler you or your developer team can examine the code relevant to server processes and loading time to help you diagnose the technical problems your site is facing. For instance, you can benefit from the Profiler’s assistance to decide if an extension you installed is generating some issues related to your store’s performance.
Magento Profiler can help you decide what your priorities are and act accordingly to them to make your website run faster and ultimately to increase your sales performance.
Magento Profiling – Who can do it and how?
Note that it is not advisable to use Magento Profiler on live sites and also that you need a basic understanding of PHP and Magento to do it, else you should ask professional assistance from your Magento developer team.
To enable Magento Profiler, go to System/Configuration/Developer/Profile and set it to “Yes”.
This will enable the profiler, but you should also go to your root index.php file and look for the commented Varien_Profiler::enable(); line and uncomment it. If the code is not there, then paste it before the following line: Mage::run($mageRunCode, $mageRunType.)
You can then refresh the page and you will see at the bottom of the page a performance table similar to the one illustrated below:
The table columns indicate the following data:
- Memory usage in bytes
- Code profiler specifies the code is being executed
- Time shows in seconds the total amount of time the code takes to be executed
- Cnt is the time count a single block of code ran to generate the output
- Emalloc is the amount of memory in bytes PHP assigned to this operation
- RealMem is the amount of memory used to process this operation
Analysing the content of the table you can make further decisions on how to improve the performance of your Magento store, whether it’s to fix or replace a buggy extension, optimize your theme or the database.
Improving Magento performance: How to make your Magento site load faster
If your Magento site is running slow and you are looking for the best tips and tricks you can use to speed up your website and make your Magento store more responsive, then you came to the right place. In this chapter you will find the best practices we encourage your to follow to optimize your site’s performance.
Our guidelines contain all the technical details you need to know to measure your website’s performance and set up your Magento store indexing settings, caching options, tools and other solutions to improve the loading speed and offer the best shopping experience for your customers.
Magento Index Management
Indexing your Magento website helps you increase the loading speed for your fontend pages.
What indexing does is to actually store all information related to your products pages and category pages into more easily accessible collections of data, so that they can be displayed accurately and more rapidly.
If your website does not have indexing enabled, then all the necessary information it needs to provide will be generated in real time, making everything more difficult to access for the server and especially for your users.
For example, the price of every item will be calculated in real time, based on the price rules and discounts you have set up for your customers. Also, layered navigation will be generated in real time based on all the attributes your products have available, and so on. So indexing is indispensable if you want to offer your customers a good shopping experience.
Managing Indexes in Magento
There are two ways you can index your Magento store: automated reindexing and manually reindexing new data about existing products on your website, or new product pages / categories you want to make available to your customers.
The default settings for each alternative is stated in Magento’s system configuration. By default, all indexes are set to “Update on Save”, which will trigger reindexing whenever a change is made from the Admin mode.
The manual updating option requires reindexing everytime you change one of your product’s attributes. You can also override the default settings for indexing and you can do this from the Action control menu.
How to manually reindex your Magento store using SSH?
To benefit from a better webstore performance you can choose to manually reindex your Magento store. In order to be able to do this, you will need SSH access to your web hosting account.
Once you have it, log in to your account via Secure Shell Protocol and go to the installation directory in your Magento store to execute the following command: php shell/indexer.php reindexall. This command will start the reindexation process which will update all data on your website.
If you have a big database it is advisable to manually initiate the reindexing process at midnight, or whenever when the activity on your website is lower, to avoid loading up the server. Remember, your website’s performance will be affected during this operation so make sure you choose the right time to do it.
Automated reindexing in Magento
Reindexing your Magento store can take a while, depending on the following aspects:
– the total number of products you have on your Magento store
– the number of store views your Magento store has during reindexing
For that reason, large websites opt to have the reindexing process be done automatically once per day, usually at a very late hour, so that users don’t encounter performance issues. This can be done by setting up a cron job on your server with the command mentioned in the manual indexing section above.
Magento cache management
How can cache management improve your Magento store’s performance?
By using Magento’s cache management system you can benefit from faster data delivery for your customers and improve your overall web store’s performance and scalability, since your website will be able to handle more user requests at the same time without crashing
Having in mind that Magento is a database platform, managing your cache will greatly improve the loading time of every query your customers perform on your website, replacing the time consuming processes which require multiple queries of the database and slow down your website.
Knowing how to manage your Magento cache system will significantly improve your webstore loading speed, create a better user performance and boost your website’s capability to serve the same content to a bigger number of customers at the same time. In the end, all these benefits will lead to better sales performance, due to an increased conversion rate and a higher ranking your website will receive from search engines.
What is caching? How browser caching and server caching work?
Every request made by a customer can load your server’s activity, but here is where caching comes in. Using browser caching and server caching can help reduce the number of requests that are sent to your server.
Managing default caching in Magento
Magento’s cache management system is designed to improve the performance of your Magento store.
The system will send you a notification when the cache should be refreshed and the steps you need to follow will be presented to you. After taking the indicated steps, make sure you refresh your browser to see the most recent files.
Magento’s cache location can be found in var/cache directory in the root of your store and can be easily managed from the System / Cache Management menu.
Types of Cache in Magento
Magento has the following types of cache, each of which can be used to improve the loading speed of your store and provide a better shopping experience for your customers.:
- Blocks HTML output
- Collection Data files.
- Database DDL operations
- EAV types and attributes
- Page Cache
- Integrations Configuration
- Integrations API
- Target Rule
- Web Services Configuration
In the cache management dedicated section you can choose to remove different types of cache by using the following actions:
- Flush Magento Cache will remove all items stored in the default Magento cache directory which correspond to Magento tags
- Flush Magento Storage will remove all the items which are stored in the cache directory.
- Flush Catalog Image Cache will remove all automatically resized images stored in the catalog/product/cache location
- Flush Static Files Cache will remove all preprocessed view files and static files
Full Page Caching
What is the Full Page Caching for Magento?
Full Page Caching is a caching solution designed for high-traffic Magento-based platform websites. It works by storing the full output of a page in a cache directory, to serve the same page content to subsequent requests users make to that very page, without loading up the server. FPC will also improve the performance of your website by avoiding crashing in the busiest time slots of your webstore.
Enterprise_PageCache is available by default in Magento Enterprise, but can be used as an extension for all online stores built on the Magento platform.
With Full Page Caching, your Magento online store can benefit from quicker loading time, an increased number of requests per second and a decreased latency for loading up a webpage. At the same time, FPC helps you improve the functionality of your server by unloading it from the unnecessary processes it needs to serve if you’re not using a caching solution.
Full Page Cache comes with a number of difficulties, especially regarding the dynamic content of your Magento store. However, by using placeholders and containers FPC can process the dynamic blocks of content, such as the shopping cart or every customer or the account links, and connected them to the static content of a page served from cache directories.
FPC is one of the best solutions which provides all the specific performance parameters an ecommerce website needs to be able to deliver a personalized dynamic page to each end-user.
If you’re on the Community version, you can opt for extensions in order to gain the benefits of FPC (unless you’re on Magento 2, which has FPC built-in). Some of the popular caching extensions are:
As mentioned, Lesti’s FPC extension is free, but is limited in certain features and does require a separate extension that handles the crawling (once FPC is enabled, crawling assures that pages are cached before users access them, and most paid extensions include this feature).
Advanced Caching Solutions for Magento
If you’ve enabled Magento’s built-in cache and configure full page caching, you can further optimize your performance via several more advanced caching solutions that are mostly installed and configured outside Magento.
There are several types of cache storages that can be integrated in Magento, some of which are intended for general use, while some target specific data and processes. In what follows we briefly discuss each of them to help you make the right decision and improve your Magento store’s performance.
Backend Caching Solutions
A backend caching system is often used to solve specific errors which can appear while using the Magento’s default file-based caching system. You can choose one of the following backend caching solutions: Memcache, APC, Redis , MongoDB, Rubic.
Although all of them can be integrated in Magento, it is not advisable to run them simultaneously, so you have to choose only one backend caching solution. We recommend you to use either MemCache or Redis.
Session Stores Caching Solutions
A session is a an interactive data exchange between two computing systems, and it is also known as a login session. As the name indicates, the information interchange is unique for every user.
During a login session user-specific data is stored on the server for each customer. The server then maps every end-user with its session using cookies. When the user returns to the store the items that have been added to his or hers cart are being displayed from the session storage. How the server manages to display the session to each user can greatly impact the loading speed of your Magento store.
OpCode Caching Solutions
OpCode Cache it is used to improve PHP server’s performance. OP cache uses shared memory to store data so that the server will not need to parse scripts on every request users make on your Magento Store.
Installing this type of caching on your server requires no additional configuration and you can control OpCode Cache from the backend of your Magento store to reset the cache. You can also check how OpCache works in real time, as the specific charts reload every 5 seconds.
You can choose one of the following OpCode Caching Solutions: APC, XCache, Eaccelerator, Zend OPCache and although you can install multiple OpCode caching solutions, it is advisable not to do so, as the performance improvement will not increase significantly.
Reverse Proxy Caching Solutions
Reverse Proxy Caching is designed to effectively improve a website’s performance. A proxy cache server functions as an HTTP client between your end-users and your web server. This solution offers lots of benefits as the traffic which is received through a reverse proxy can be monitored, data flow can be filtered and cached, also additional security configurations can be set up.
The most popular reverse proxy caching methods used are nginx and Varnish, and our recommendation is to use the latter, which we will unfold in the following sections of our performance guide.
Advanced Caching Tools recommended for Magento
To improve your Magento web store’s performance you can simultaneously use different advanced caching solutions. The most popular ones are listed below:
MemCache is an open-source generic caching system that can be integrated in Magento. MemCache is designed to decrease the database load and reduce the number of times an external source (a database or an API) must be accessed to provide the specific data of a search request made by end-users on your Magento store.
Redis is another open-source generic caching solution, that can be implemented in Magento. It uses an in-memory data structure store as a database cache and it supports different sets of data, such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.
Redis can be used for PHP session storage and it has powerful features which are not supported by memcached storage solutions.
Redis relies on database queries and disk reads, but it has significant advantages that can increase the efficiency of your Magento store, such as caching data and serving it significantly more quickly, it is volatile especially during server crashing, can be used across multiple servers.
The Alternative PHP Cache – APC
The Alternative PHP Cache is an PHP extension that can be integrated at server level of your Magento store to help you improve your PHP server’s performance (see OpCode Caching above). APC caches the compiled operation codes of PHP scripts and enables your website to display the content of a page more rapidly to end-users.
To use APC with Magento you just need to install the PHP module and restart the server, so that your Magento website immediately improve its loading speed.
Varnish Cache – VC
Varnish Cache is a powerful open source HTTP engine and reverse HTTP proxy specially designed to help you dramatically improve the speed of your website. VC can be installed on Magento to improve your online store overall performance.
Check out how more about how you can benefit from using Varnish Cache Server with Magento in the next section.
Varnish Cache Server with Magento
What is Varnish Cache and how it works?
Varnish Cache is one of the best solutions for full page caching you can use for your Magento store to improve the loading speed of your website.
Varnish Cache is an open-source HTTP reverse proxy that can be installed locally on your server or on a distributed server network. It is designed to deliver a storage copy of a web page, which is actually a cached version of a page located on your server, and process all requests users make to access that specific page by displaying its copy.
Varnish Cache acts as a server that runs at the halfway distance between the interface of your website the end-user sees and your Magento web server. It is responsible for managing the requests users make and serve them the relevant content they want to see from cache directories.
To make sure your Magento gets the best use out of Varnish Cache, you should cache as much content you can, such as partially dynamic pages and HTML elements, in order to reduce the amount of work your server has to do and benefit from improved scalability and performance for your store.
That means that Varnish caching should not replace other types of caching you have installed, such as a Magento Full Page Cache extension. It is best that they are used together to maximize the number of concurrent users your site can support without suffering from performance issues.
What type of content can Varnish Cache serve?
Varnish Cache works with both static and dynamic elements your website contains to ensure a faster navigation for customers on your Magento store.
Caching Dynamic Objects in Magento with Varnish Cache is partial. This is due to the fact that dynamic elements depend on each user’s actions on your website, to make sure that the content of each customer’s cart will be unique. However, with Varnish Cache you can control and improve the caching level of the dynamic elements on each page, such as the number of products in user’s shopping carts or their value.
Varnish Cache Installation in Magento
In order to benefit from the advantages Varnish Cache offers for your Magento Store when it comes to your store’s performance, you need to install the Varnish Cache Extension and configure the server, to meet the technical configuration both servers need to accurately and promptly respond to each request users make on your website.
To be sure you have set up the extension to work properly with other caching solutions you already use for your Magento store, you may need to consult a Magento expert.
Keep in mind that Varnish Cache can be used together with Magento default cache system and also with other caching tools to improve your website’s performance and offer the best shopping experience for your customers.
In the graphic below you can see a performance comparison between different caching solutions in Magento:
CDNs – Content Delivery Networks
CDN Uses and Benefits
Implementing a Content Delivery Network with your Magento store will load the content faster for every customer that enters your website regardless of their location.
This means that your content will be provided to them more rapidly, as it is served not from your web server, but from the CDN system that functions as shared web servers hosted in different locations worldwide.
Additionally, by choosing to use a CDN you can benefit from a more secure website, blocking harmful requests which attempt to steal the private data of your clients and may try to deny access to your entire website.
How CDNs works
Having a CDN can greatly improve the shopping experience of every customer around the world. For example, if your web server is located in USA, then an image of a product you have in your Magento store will load faster for USA customers, than for the customers outside USA.
Content Delivery Network can make your website more responsive by delivering the same information to all customers around the world equally faster because it identifies each and every user’s location and serve the same information by accessing the closest web server available.
To do this, a CDN makes a copy of, say, a product image, then distributes it to different web servers around the world, to make sure that regardless of the location a customer enters your website, the content is quickly loaded on your behalf. This translates into a higher transfer rate (throughput) for every static element on every webpage and reduced latency rate for your website.
CDN works best for CSS files, JS files and images. Using a Content Delivery Network in Magento will help your web store load these files more rapidly and simultaneously on a page, compared to processing each and every file one by one by a single web server, as it usually is the case in the absence of a CDN.
Using CDN with Magento
Keep in mind that for Magento there is no full integration with a specific CDN and making the right choice and the necessary settings to configure your CDN server is your responsibility. If you do not have the technical knowledge to integrate your Magento store with a CDN server on your own, we recommend you to ask for an expert’s assistance.
Another alternative is to use an extension, such as CloudFront CDN which helps you configure your Magento store to use the Amazon CloudFront Content Delivery Network to serve all the static files your store has, such as CMS Images, CSS files and JS files. This alternative is simple to install and use, so no technical knowledge is required to have if you choose to use this option.
Compressing CSS and JS files into a condensed file is another option you can choose to use in order to reduce the page load time on your Magento store and optimize the performance of your website.
To merge CSS and JS files go to the Admin panel and click “Stores.” In the settings section select ”Configuration” and then ”Developer,” under the Advanced section on the left side of the page:
- To merge CSS files, go to CSS files section and select the “Yes” option.
- Finally, choose “Save Config”.
After enabling merging CSS and JS files, you will observe a reduction of CSS and JS file requests send to the server, as in the example below:
Magento Database Maintenance
Why is log cleaning necessary for a better performance?
Large databases can often decrease the loading time of your website, so managing your database by cleaning the logs can boost your site’s loading speed and reduce your latency rates in processing database queries, resulted after every search users make on your website, thus improving your website’s overall performance.
Magento databases save a lot of data in order to track down every order customers make so that every user can have access to view their shopping history, together with all their purchased products, and track down their orders in real time.
By regularly cleaning your Magento store logs your website will load faster and offer a better shopping experience for your customers.
Optimizing database log cleaning in Magento
E-commerce websites’ databases can benefit from a decreased size up to 75% and faster data processing after executing log cleaning operations, so optimizing your Magento database is one the most important tasks you need to consider to make your site perform better.
Although Magento has a built-in method to regularly clean the logging data, this option is not set by default so that every user can choose whether to turn it on, and as it is expected most don’t.
Therefore you have to do it yourself either automatically or manually, to benefit of more MySQL database space and boost your Magento database efficiency in processing all queries.
Before you proceed to log cleaning it is recommended to do a backup, especially if you are not sure what data to clear up, as some information will be lost during this process, like specific data about your Magento website’s visitors.
How to automatically clean logs in Magento?
To optimize your Magento database log cleaning automatically, go to Admin, choose “System/Configuration” and then in the left menu in “Advanced” click on “System”. Set the “Log Cleaning” box to “Yes” and configure the “Save log” for 15 days. Then “Save Config”.
How to execute a manual log cleaning in Magento?
You can also choose to clean logging data much manually and you can do it via directly accessing the database via a tool such as phpMyAdmin. This option is usually a faster way to clean the logs than by Magento built-in feature explained above, plus it gives you the opportunity to clean other tables which are not included in Magento’s default feature, such as:
By cleaning your logs, all the data contained in the selected tables will be consolidated, which will result in a decreased database size up to 95%.
To execute a manual log cleaning in Magento, go in phpMyAdmin to open the database and in the right window select the following table types:
Click the drop down box situated at the bottom of the page and choose “Empty”, then click “Yes” on the confirmation window and you’re all done. The selected logs are all cleaned up.
Enabling Flat Catalog
By default, Magento stores all catalog data in tables designed after the Entity-Attribute-Value (EAV) model, but because all product attributes are saved in many tables, SQL database queries can take a long time to respond and process the request, so the entire activity on your website will be slowed down.
Using a flat catalog can help you create new tables which are automatically updated and can be rapidly indexed to process all the information your Magento catalog contains and all your pricing policies details, so that your store will perform better and benefit of reduces query complexity of database queries and also reduce the load on MySQL server.
The benefits can be observed more easily if you have a big number of products and categories, so the flat catalog feature will work better, especially if you have a big Magento web store.
To enable Flat Catalog feature in Magento, go to the “Admin” sidebar and click on “Stores”. Under the “Settings” section, choose “Configuration”, then choose “Catalog” from the panel displayed on the left side of the screen. Set “Use Flat Catalog Category” to “Yes” and “Use Flat Catalog Product” to “Yes” and, finally, “Save Config”.
Using Magento Compiler
Magento Compiler is a default feature in Magento that allows you to compile all the installation files and create a single path for them, in order to improve the performance of your website and increase the loading speed of your Magento store up to 10-20%.
The compilation option is designed to be used by Magento owners especially if their website is running too slow, due to a big number of files the server needs to access on each request users make when visiting the store.
To use this tool you should make sure the file ”includes/config.php”, which can be found in the directory ”includes”, must be writable.
Also, note that the Magento compilation feature should be disabled whenever you make any changes to your Magento installation files. When the changes you want to make are done, run the compilation process, and then enable the compiler again.
Using a hosting environment with PHP7
PHP7 is the latest version of PHP, and it offers significant performance benefits for both Magento 1 and Magento 2 websites. According to a recent study by MageCore, Magento 2 sites can almost double in performance by using PHP7 versus the previous PHP5 version:
Note however that Magento 1 isn’t compatible with PHP7 out of the box, but there are some extensions (such as this free one from Inchoo) out there that allow your store to run with minimum effort.
Improving your Magento’s site performance is more than a must, if you want to keep ahead of your competition and increase your sales. Plus, having a fast loading website can help you increase your website’s ranking for every page of your store and offer a good user experience for your customers.
If you have any difficulties in improving your website’s performance based on the steps we presented in this guide, we advise you to seek assistance from experienced Magento developers!
Do you want to improve your Magento’s website performance? Don’t wait – let’s talk today!