How to speed up Magento – Top 10 proven ways [Updated 2018]
Magento is a popular eCommerce app for a lot of reasons – it’s secure, feature rich and super stable.
BUT, it has an Achilles’ heel – Poor Speed
The default settings in Magento is not optimized for speed, and pages can take up to 10 seconds to load.
But, Google expects your pages to respond in 200 milliseconds, and fully load within 2 seconds. So, if you’re using Magento out of the box, it’s akin to business suicide.
Don’t worry though. Here’s help.
We’ve configured hundreds of Magento sites, and maintain a lot of high traffic ones. Here are a few simple steps to make Magento fast.
1. Enable Magento Caching
When a visitor accesses a page, Magento looks through many configuration files, executes several scripts, loads not less than 10 template files, and runs a truck load of database queries.
All that takes a LOT of time.
It’s madness to make Magento do it every time someone refreshes a page.
Instead you can ask Magento store every processed page in a directory called “Var/Cache”, so that the next time a visitor asks for the same page, it can be quickly delivered from the cache.
To enable caching, login to the Magento admin panel, and click on “System > Cache Management > Select All > Actions (Enable)”.
Still not fast enough?
Most sites use SATA hard disks, which are pretty slow. So, even if caching is enabled, busy sites can still be slow.
2 common ways in which we resolve this are:
- Using system memory for caching – We create a “tmpfs” partition in the server, and mount the “Var/Cache” folder on it. So, cache access will be lightning fast.
- Using SSD for cache directory – The setup faster SSD drives instead of old SATA hard drives to store Magento cache and database. This could be slower and more expensive than the first option, but can support a higher volume of data.
If you are not sure how to set this up, we can do it for you. Our Magento experts are on standby 24/7. Click here to request Magento cache setup.
2. Combine CSS and JS
Each page in Magento consists of many “blocks” of code, which in turn consists of many CSS and JS files.
Every time someone refreshes a page, each of these files are fetched on after another, which is a huge drain on site speed.
You can cut down the loading time by more than 50% by merging all JS and CSS files. To do that, go to “System > Configuration > Advanced > Developer” in the Magento admin login, and enable “Merge files” as shown here:
Warning : Some sites that have custom code is known to break when combining scripts. If you’re not sure of your site’s dependencies, get expert assistance.
You can further cut down the load time by using HTTP/2 instead of HTTP 1.1 which is enabled in all web servers by default.
HTTP/2 saves time by using faster binary data transfer (instead of older text format), using a single connection (instead of spending time opening multiple ones), compressing headers, and transferring important files first.
If you have a question about how to setup HTTP/2, we’d be happy to help. Open a request at our server administration service page.
3. Add a fast reverse proxy server
Your server sends HTML files to a visitor’s browser.
What if another visitor requests the same file?
If you’ve enabled Magento cache, it’ll fetch the pre-compiled bits from cache, assemble it into a HTML file, and then send it to the visitor.
It’s still a lot of work. What if your server can just give the same file from memory?
You can do that with a reverse proxy. Almost all popular web servers can be configured as a reverse proxy. Here are the top few:
- Nginx – This is the hot favorite right now for the top busiest websites (as per Netcraft Jan 2018 survey). We’ve used it for small and large content heavy sites. It has proven to be reliable against traffic spikes, and is a safe bet because of its stability and customizability.
- Varnish – A bit more complex than Nginx to deploy, but sites with heavy traffic and a lot of content (eg. online publishers) can see considerable gain in speed with Varnish.
- Lighttpd – If you have a monster site, and resource usage spikes are common, Lighttpd can help you out. It’s light weight and not likely to drag down the server.
Of course, there are way many more options such as Squid, Apache or IIS, but these are the most popular and successful options.
The one ideal for your environment need to be found out by looking at your complexity of the application, the site load, and your web configuration.
If you have any questions, head over to our server administration services page, and our experts will help you out.
4. Defragment database tables and optimize server settings
Every day, visitors post new comments, you add new products, modify or delete old products, and add new pages.
All this activity leaves “holes” in the database tables. These are little gaps where a data was deleted, but was never filled back in. It is called “fragmentation”, and can cause longer data fetch times.
Database tables that have more than 5% of it’s size as “holes” should be fixed.
So, every month (at least), check your database tables for fragmentation, and run an optimization query. It’ll keep your site from turning sluggish.
Optimize database server settings
Every time you upgrade Magento or add a new extension or module, the kind of queries executed on the database changes. And as the traffic to your site grows, the number of queries executed on the database increases.
That means, the load on your database keeps changing as your site grows older and more complex. If your database settings are not adjusted to accommodate these changes, your site will run into Memory or CPU bottlenecks.
That is why it is important to monitor database metrics such as query latency, slow queries, memory usage, etc. and make timely setting changes to prevent issues.
If your database has not been optimized in a while, your site might be due for one.
If you are not sure how to go about it, we can help you. Our database experts are online 24/7. Click here to contact them.
5. Upgrade your PHP engine
Many Magento owners use applications that are installed by default in their servers.
For eg. CentOS servers use PHP 5.4, not the latest PHP 7.2 with FPM (FastCGI Process Manager) that has enormous speed advantages.
Magento store owners who use VPS, Cloud and Dedicated server owners are often unaware of the differences and keep trying to optimize their site code to fix speed issues.
By just changing the PHP engine, tweaking the settings to match the site load, and enabling PHP cache, we’ve been able to improve Magento load speeds by more than 100% in some cases.
If you have never changed your default application settings, maybe you have a low hanging fruit right there.
Talk to our server experts at the on-demand server administration page, and we can fix your server up real quick.
6. Optimize store images
Every Magento store has images.
Images are bulky, and take more than 50% of an average Magento page’s bandwidth and loading time.
You can reduce your site’s loading speed by up to 25% by reducing the size of all images in Skin, Products and Categories.
This can be done by using PC applications such as Gimp or by online tools such as TinyPNG and TinyJPG.
7. Delete extensions and modules
Magento Marketplace has thousands of extensions and themes. It’s hard to resist the allure of trying a few of them.
The trouble starts when you forget about unused extensions.
This is an additional set of code added to the website, and possibly executes every time someone accesses a page.
So, if you have tried extensions in the past, take a look at the list, and delete the ones you don’t need. You can do this by going to “System > Configuration > Advanced > Advanced”, and selecting “Disable”.
Warning : Some extensions might be needed for others to function. Also, if you have caching enabled, cache need to be disabled and cleared before you disable extensions. If any of these goes wrong, your site could end up broken. If you have any questions, we can help you out. Click here to request assistance from a Magento expert.
8. Enable Flat Catalog, Magento Compiler and Log cleaning
We maintain Magento sites for several eCommerce companies.
In many of these sites, we enable additional Magento settings to improve speed. These settings are enabled based on the site’s configuration, customization, and other factors.
Here’s a quick run down:
Enable flat catalog
Magento performs several database queries fetch information for a single page.
By enabling the option called “Flat Catalog Category” and “Flat Catalog Product”, you can ask Magento to merge all category and product data into one table.
So, instead of executing multiple queries, Magento has to execute just one database query, thereby saving significant amount of time.
Enable Magento compiler
Magento loads several linked PHP scripts in order to display each page. This leads to a lot of search, locate, and retrieve operations to get all the files from different locations. Needless to say, it leads to a perceptible lag in page display.
Magento provides a feature called “Compilation” that puts all the commonly accessed files into one single directory, making access to PHP scripts super fast. It can be enabled by going to “System > Tools > Compilation”, and hitting “Run Compilation Process”.
Enable log cleaning
Magento stores everything in its database.
This includes product data, page data, and activity logs. It records visitor details, what products they viewed, how many times it was viewed, etc.
The default option for Magento is to store this information indefinitely, which can easily take the size of a database to several GBs.
Cleaning out these logs on a regular basis makes the database lean, and responds faster to queries. It can be enabled by going to “System > Configuration > Advanced > System > Log Cleaning > Enable Log Cleaning”.
Bonus tip : Re-index data periodically
Magento uses an ‘Index” to quickly access product information.
Every time a new product is added, this index table is automatically updated.
But it often contains stale data from old products – which reduces performance.
So, in the sites we maintain for our customers, we manually Re-Index all products at least once weekly (for sites that keep adding/removing products). This keeps the Index tables clean and fast. Re-indexing is done by going to “System > Index Management > Reindex Data”.
If you need help with maintaining your Magento store, we can build a custom plan to meet your needs and budget. Click here to ask for a custom quote.
9. Update Magento
New versions of Magento not only gives you more features and bug/security fixes, but with every update Magento performs better.
So, every time an update comes out (no matter how small), we update our customer sites to the latest version.
This helps us keep these sites, fast, secure and feature rich.
10. Switch your hard drive to SSD
OK, as the last point, take a look at your hard disk.
The biggest drag on server performance is disk I/O. That is the time taken for the hard disk to spin, spin and spin to collect all the data your site needs.
In 2018, you don’t have to wait for that. There are SSD storages which functions much like the server memory. No spinning.
So, get an SSD disk for at least your database partition. It alone can cut down your load time by close to 10%.
Magento is a favorite of many eCommerce site owners because of its security and features. But in its default settings, it is really slow. Today we’ve seen the top 10 fixes to make Magento load faster. This includes Magento admin area tweaks as well as web and database server optimizations.