Loading..
Processing... Please wait...

Product was successfully added to your shopping cart.



Speed up Magento 2 and 1 - The Ultimate Guide (Updated 2018)

Speed Up Magento 2 and 1 - The Ultimate Guide (Updated 2018) Do you want to speed up Magento 2 or 1? Of course you do! And you are not alone. Magento, one of the most popular eCommerce platforms, might be slow. The main reason for its poor performance is an excessive use of various customizations. Here are the 34 field-proven steps that will help you do Magento 1 and Magento 2 performance optimization:

34 Magento Optimization Techniques:

  1. Optimize TTFB
  2. Minimize Latency
  3. Magento Server Configuration
  4. Choose Fast Hosting
  5. Optimize VPS for Magento
  6. Audit Magento code
  7. Optimize Start Render Time
  8. GZIP Compression
  9. Domain Sharding
  10. Utilize The Power of HTTP/2
  11. Leverage Browser Caching
  12. Prioritize Above-the-Fold Content
  13. Remove Render-Blocking CSS and Javascript
  14. Reduce the Size of Visible Content
  15. Put Above-the-Fold Content First
  16. Optimize Document Complete Time
  17. Magento Image Optimization
  18. Sign up for CDN
  19. Optimize Fully Loaded Time
  20. Don't Abuse jquery.ready
  21. The Less Third-Party JS the Better
  22. Never Use JS bundling (Magento 2 specific)
  23. Run Store in Production Mode (Magento 2 specific)
  24. HHVM (HipHop Virtual Machine)
  25. Disable Shipping Methods You Don't Use
  26. Remove Estimated Shipping Cost Block From Cart Page
  27. Optimize Shipping Rates Collection
  28. Disable Gift Message Extension
  29. Disable Configurable Swatches Observer on a Checkout Page
  30. Full Page Cache Extension
  31. Upgrade to PHP7
  32. Make Varnish Your Caching Application
  33. MySQL Tuning
  34. Perform 3rd-party Extensions Audit

I will show you how to increase the speed of the Magento site in a second, but first let us define what we will use to measure site speed.

How to Measure Magento Speed

When a browser loads a web page it does certain actions:

  • It receives html data from a server.
  • It analyzes data and loads external files you might have on the page (CSS/JS/images/fonts etc).
  • It builds what is called a DOM (Document Object Map).
  • It renders the page (puts elements on the screen).

We can define 3 time periods that measure how quickly a webpage loads:

  • Time to first byte (TTFB) or server response time: the time from when a user clicked on a link or typed in a site URL until the first bit of information from the server arrived.
  • Start render time: the first point in time that something was displayed to the screen. Before this, a user was looking at a blank page.
  • DOM complete or document complete time: the point in time when the browser considered the page loaded (onLoad javascript event fired). All the content has been loaded except content that is triggered by javascript execution.
  • Fully loaded time: a webpage is loaded and no network activity is performed by a web browser.

Definitions are taken from webpagetest.org. TTFB < Start render < DOM complete < Fully loaded

The waterfall chart The Waterfall Chart

The most important time in my opinion is the start render time. The quicker you show a user that something is happening after he requests a webpage, the faster the site will appear to the user.. There are 3 main time limits that describe user perception of how quick a web application is [study]:

  • 0.1 second response time – a user feels that a system is reacting instantaneously.
  • 1.0 second response time – a user notices the delay, but it doesn't bother him.
  • 10 second response time – the limit for keeping the user's attention focused. For longer delays, a user will want to perform other tasks while waiting for the computer to finish.

We want to keep start render time around 1 second to make a user feel a website is fast. Alright, enough theory. Here are the 34 Magento speed optimization steps:

1. Optimize Time to First Byte

Server response time, or time to first byte (TTFB), consists of the time a browser's request goes to the server and the server response goes back to a browser (latency) and the time a server generates HTML. Google recommends having TTFB around 200ms. 1s TTFB is considered bad. To reduce server response time Magento codebase needs to be inspected. Here are my in-depth tutorials on how to optimize TTFB for Magento 1 and Magento 2.

2. Minimize Latency

Host your website as close to your main audience as possible. If you sell shoes in London, do not sign up for hosting in Japan. Common sense. Do not think that SSL will impact your TTFB much. SSL negotiation time is negligible but the SEO benefit is obvious.

3. Magento Server Configuration

Optimizing server configuration includes choosing the right hosting and setting up server software. Magento 1 and Magento 2 performance optimization starts with following the hardware requirements:

  • Do not pick a cheap option here. It is the basis of your online store.
  • Secure as many resources as you can afford and a bit more.

You might want to get more CPU and RAM if you come to Magento 2 from Magento 1. 2.x needs more of it.

4. Choose Fast Hosting

A Magento site can't run on $5/mo shared hosting. If you want good TTFB and start render times, sign up for VPS or Magento-optimized hosting – Nexcess, Lexiconn and others. Do a Google search and see what others recommend.

5. Optimizing VPS for Magento

If you plan on running VPS or a dedicated server, you need to optimize server software and a database.

Options for your server setup are endless and depend on your expertise. You can configure NGINX, Apache, Varnish, HHVM, php-fpm, Redis, memcache.

Here are possible solutions for magento performance tuning:

  1. Varnish + NGINX + PHP-FPM + Redis

  2. Varnish + NGINX + HHVM + Redis

  3. Use PHP7 with Magento 2 or PHP7 + Inchoo patch with Magento 1.x

  4. Host webserver and database on different servers

  5. Use MySQL master-slave replication for separate reads and writes

5.1 Server Performance Hogs

Here are common server misconfigurations that slow Magento sites:

  • Disabled MySQL query cache. Modern MySQL servers come with query cache disabled by default. Enable it. By the way, it is one of the first things to check on my magento performance optimization checklist.
  • Slow disk I/O. Make sure your host provides you with SSD (solid state disk) storage.

  • RAM shortage. When the system runs out of RAM, it puts data on disk (swap), making things slow.

6. Audit Magento Code

Your Magento site php code and template files are the main reason for poor server response time.

First, you need to profile the code and identify parts that slow the site down. Magento comes with a built-in profiler you can use. You can use third-party extension Aoe Profiler or sign up for the NewRelic application performance management tool.

6.1 Magento Code Performance Hogs

  • Observers that run on every page request

  • Poorly written template files

  • A slow MySQL query(s) somewhere

Here is a detailed tutorial on how to optimize TTFB with Magento profiler.

6.2 Poorly-written Magento Code

Here’s an example of bad Magento code that I encounter often:

Loading Magento models inside a loop. That happens in product list templates; people iterate over product collection and load the product model every time:

foreach($collection as $product){
  $product = Mage::getModel('catalog/product')->load($product->getId());
....

Don't do that. It’s better to construct your collection to have all the data you need. Magento model loads are expensive.

7. Optimize Start Render Time

Start render time (SRT) is the first point in time when a user sees the content after requesting the webpage. It could be a background image or some text blocks, but from that time on the user knows something is happening. In my opinion, start render time is one of the main factors by which a user judges how fast the site is.

According to the 3 main time limits [study] I mentioned earlier, we need to keep the start render time to around 1 second.

SRT consists of:

  • Time to first byte (TTFB)

  • Time it takes to download a page HTML

  • <head> section parsing and downloading resources (JS/CSS external files) a browser finds there

  • Initial layout calculation

After we understand what start render time is, we have options to optimize it.

8. GZIP Compression to Shrink Page Size

Compress your html page so that a browser has fewer kilobytes to download. Enable gzip compression on the server side – see instructions for your web server. Confirm you have gzip enabled by this online testing tool.

8.1 NGINX GZIP Compression

NGINX example configuration to enable gzip:

http {
        gzip on; 
        gzip_disable "msie6";

        gzip_vary on; 
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k; 
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

You need to restart NGINX for the changes to take effect.

8.2 Apache GZIP Compression

When running Apache you can enable gzip by changing .htaccess file inside your Magento root folder:

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

9. Domain Sharding

Domain sharding is splitting external resource files (JS/CSS/images etc) across multiple domains. Why bother? Because a browser can download files in parallel but has a limit per domain. For example, Chrome can do 6 concurrent connections.

If we can split images, js, and css files across multiple subdomains, we can make a browser download resources a lot faster.

UPDATE: domain sharding is not needed when you use HTTP/2. And the use of HTTP/2 is recommended.

9.1 Domain Sharding in Magento

Magento supports domain sharding by default and it is easy to set up:

1. First create subdomains:

  • skin.domain.com

  • media.domain.com

  • js.domain.com

Next, point them all to the same IP and file folder your main domain is pointing to.

2. Go to Magento backend main menu System > Configuration > Web and set Base Skin URL, Base Media URL, and Base Javascript URL for unsecure and secure (if you have one) links.

3. Flush cache and confirm your resources are now served from subdomains.

10. Utilize the power of HTTP/2

HTTP/2 is the new generation of Hypertext transfer protocol. It has many performance improvements that allow a browser to load a webpage faster and be less resource-intensive.

Here are the key differences to HTTP/1.x:

  • HTTP2 is binary, instead of textual.

  • It is fully multiplexed ( can send multiple requests over the same connection ).

  • It can use one connection for parallelism ( meaning it can load resources considerably faster).

  • It uses header compression to reduce overhead.

  • It allows servers to "push" responses proactively into client’s browser caches.

All major web servers (Apache, Nginx, IIS) support HTTP2 out of the box. Here are the examples of configuration:

10.1 Enable HTTP/2 for Apache

Apache can use the latest HTTP protocol from version 2.4.17 up. First install mod_http2 module. Next enable it:

LoadModule http2_module modules/mod_http2.so

And modify Protocol directive:

Protocols h2 h2c http/1.1

10.2 Enable HTTP/2 for Nginx

You will need Nginx 1.9.5 up. All you will have to do is to add http2 parameter in listen directive.

server {
                 listen 443 https;

.....

You can use Google Chrome Developer Tools to verify the correct installation (if you are using chrome browser). Open it up, go to Network tab and check for Protocol column - it should say h2. (To view Protocol column right click on any column and select it):

HTTP/2 Verification HTTP/2 Verification

11. Leverage Browser Caching

A browser can cache files for faster access. You can take advantage of this to lower the start render time. Configuration depends on your server:

11.1 Leverage Browser Caching for NGINX

Add this inside server directive:

  server{
       .....      
        location ~* \.(js|css|png|jpg|jpeg|ico|gif|pdf)$ {
              expires 300d;
              add_header Pragma public;
              add_header Cache-Control "public";
        }

11.2 Leverage Browser Caching for Apache

Add this into your .htaccess file:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

as taken from Gtmetrix.

12. Prioritize Above-the-Fold Content

Above-the-fold content is the part of a page that you see before you scroll down. It is also called visible content.

Prioritize visible content – load and display it as quickly as possible.

How do I optimize above-the-fold content? Here are some tips:

13. Remove Render-Blocking CSS and Javascript

The less time a browser spends parsing <head> section of your webpage the better. Ideally, only JS and CSS need to display above-the-fold content which should be put in between head tags.

Go through your css files and identify rules that are applicable to visible content. Inline thes rules and dothe same for javascript.

Here is an extension to defer Javascript parsing (remove render-block Javascript).

14. Reduce the Size of Visible Content

The less visible content a browser has to download the better. Make sure images are optimized. Remove any content that is not needed.

15. Put the Above-the-Fold Content First

Analyze the page HTML and make sure visible content goes first.

16. Optimize Document Complete Time

Besides start render time and first byte time improvements, there are a few things you can do to decrease document complete time:

17. Magento Image Optimization

In my practice I use 3 techniques to reduce image size:

  1. Command-line Tools

  2. PageSpeed Server Module

  3. Google PageSpeed Insights

Let’s go over each of them in details

1. Command-line Tools

If you are familiar with Linux and Bash this tip will work for you.

I use:

  1. Gifsicle to compress GIFs

  2. Jpegtran to handle JPEGs

  3. Optipng to take care of PNGs

Here is a simple script to help you optimize images in bulk:

#!/bin/bash
find ./media -iname '*.gif' -exec sh -c ‘gifsicle -b -O3 -o "{}.out" "{}"; mv "{}.out" "{}"' \;
find ./media -iname '*.png' -exec optipng -o5 -keep -preserve '{}' \;
find ./media -type f -iname '*jpg' -exec sh -c 'jpegtran -outfile "{}.out" -optimize "{}"; mv "{}.out" "{}"' \;

2. PageSpeed Server Module

In an attempt to make internet faster, Google created PageSpeed Extension.

This is special software you plug into your server.

It compresses images on the fly, as well as other things needed to speed up a site.

3. Google PageSpeed Insights

Setting up the PageSpeed module sounds too techy for you?

No problem....

Google has a solution: Insights.

What are the insights?

It is a free magento speed test tool.

At the bottom you will see a link to download optimized images for the page tested.

Google Pagespeed Insights Google Pagespeed Insights

It is a tedious task to compress images for all the page using Insights.

But…

Done once, it could make a huge difference in how fast your site loads.

PS: There are various Magento image compression extensions available on the market.

Some free, some cost, but…

They all require professional installation.

If you want to try some of them, make sure it is installed by an expert.

18. Sign up for CDN

Content Delivery Network (CDN) is a web service to host your Magento site external resources likeCSS/JS files, images, fonts, etc.

It aims to serve those files a lot faster than you can with your own server.

I think that CDN is better than any magento image optimization extension.

Magento supports CDN by default, no extensions needed. Go to System > Configuration > Web and set secure/unsecure URLs for media, skin, js resources.

There are many CDN providers to choose from: MaxCDN, KeyCDN, Amazon CloudFront and others.

19. Optimize Fully Loaded Time

If you have done start render, first byte, and document complete times optimization, there is a final step – fully loaded time improvements.

What to do?..

First, keep the number of 3rd-party JS scripts to a minimum.

Second, do not rely too much on jquery.ready.

20. Don't Abuse jquery(document).ready

Choose onLoad events carefully. Don't put CPU intensive tasks in jquery.ready – it slows down page loading.

21. The Less Third-party Javascript the Better

Examine what third-party javascript files you add to your Magento store.

Do you really need them?

Well-known JS code like Google Analytics and Facebook are all optimized and performance impact is negligible.

Others – use with caution and always test.

22. Never Use JS Bundling (Magento 2 specific)

Magento 2 can group JavaScript files to lower HTTP requests a browser needs to make to load a page. This is supposed to make a site faster.

Let me first say that JS Bundling is useless if HTTP/2 is enabled.

Second, it does more harm than good. The bundled JS file is huge in size (5-13Mb), which makes mobile speed suffer significantly (here is a bug report).

I advise to keep JS bundling off. Go to backend dashboard > Stores > Configuration > Advanced > Developer > Javascript Settings and set Enable Javascript Bundling to No:

Turn off JS Bundling Turn off JS Bundling

23. Run Store in Production Mode (Magento 2 specific)

I would list Run Store in Production Mode as a priority on any Magento 2 speed optimization checklist.

M2 has three running modes: default, developer, and production. Production mode is the fastest one.

Make sure you always put your store in production mode. It will speed up Magento 2 significantly.

You will need to obtain SSH (Secure Shell) credentials to change running modes.

Here’s the command to find out what's the current mode:

php bin/magento deploy:mode:show

To switch to production:

php bin/magento deploy:mode:set production

24. HHVM (HipHop Virtual Machine)

This is what Facebook is using to make its pages incredibly fast (yes Mark Zuckerberg uses PHP).

HHVM is a special server software that you can install and hook up with Magento.

It replaces php-fpm and can work directly with Nginx or Apache.

I benchmarked HHVM against standard PHP-FPM5:

PHP-HHVM goivvy website benchmark PHP-HHVM goivvy website benchmark

As you can see I had 12 / 3 = 4 times increase in performance!

I hear you asking, “Is this possible for my website?”

Probably yes, but…

There are exceptions. HHVM:

  1. ...doesn’t support all features of PHP7 so it might not run Magento 2 well enough.

  2. ...doesn’t have ionCube support. If you use encoded extensions you are out of luck.

  3. ...has a set of known problems running Magento 1.x

What are these known problems?

1. Tax not applied at the checkout

The problem is with sorting implementation of HipHop VM.

Use the below patch as a fix:

diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml
index f32ac46..852865d 100644
--- a/app/code/core/Mage/Sales/etc/config.xml
+++ b/app/code/core/Mage/Sales/etc/config.xml
@@ -1218,7 +1218,7 @@
                     </subtotal>
                     <shipping>
                         <class>sales/quote_address_total_shipping</class>
-                        <after>subtotal,freeshipping,tax_subtotal</after>
+                        <after>subtotal,freeshipping,tax_subtotal,msrp</after>
                         <before>grand_total</before>
                     </shipping>
                     <grand_total>
@@ -1227,6 +1227,7 @@
                     </grand_total>
                     <msrp>
                         <class>sales/quote_address_total_msrp</class>
+                        <before>grand_total</before>
                     </msrp>
                 </totals>
                 <nominal_totals>

2. Amazon payment method doesn’t work

This involves a different array implementation of HHVM.

The patch:

diff --git a/app/code/community/Amazon/Payments/Model/Api.php b/app/code/community/Amazon/Payments/Model/Api.php
index f79e4d4..5513810 100644
--- a/app/code/community/Amazon/Payments/Model/Api.php
+++ b/app/code/community/Amazon/Payments/Model/Api.php
@@ -38,7 +38,8 @@ class Amazon_Payments_Model_Api
                 'region'             => $this->getConfig()->getRegion(),
                 'environment'        => ($this->getConfig()->isSandbox()) ? 'sandbox' : 'live',
                 'applicationName'    => 'Amazon Payments Magento Extension',
-                'applicationVersion' => current(Mage::getConfig()->getNode('modules/Amazon_Payments/version')),
+                //'applicationVersion' => current(Mage::getConfig()->getNode('modules/Amazon_Payments/version')),
+                'applicationVersion' => '1.3.0',
                 'serviceURL'         => '',
                 'widgetURL'          => '',
                 'caBundleFile'       => '',

Long story short, you will benefit from HHVM if:

  1. You have an engineer (or two) who could set things up

  2. You have a budget to support its maintenance

25. Disable Shipping Methods You Don’t Use

Magento comes with some shipping carriers (like FEDEX or USPS) enabled by default.

Even if you don’t plan to use them, they still send requests to external gateways thus slowing down the checkout process.

Here is a little experiment to give you an idea….

I took a stock Magento 1.9 and went to a checkout.

Here are approximate shipping rates request times:

Save Payment Shipping Rates Time Save Payment Shipping Rates Time
  • Fedex - 600ms

  • UPS - 424ms

  • USPS - 406ms

  • DHL - 518ms

As you can see, we are talking about 600 + 424 + 406 + 518 ~ 2 seconds of wasted time.

How do you avoid this?

Go to System > Configuration > Shipping Methods (Magento 1) or Stores > Configuration > Sales > Shipping Methods (Magento 2) and disable carriers you don’t use.

26. Remove Estimate Shipping Cost Block From Cart Page

As you might notice, when running a Magento store there is an estimated shipping cost block on a cart page.

Estimate Shipping Cost Block on Cart Page Estimate Shipping Cost Block on Cart Page

Do you find it useful?

If not, remove it.

Reason? It increases page load time.

To make it disappear add the following lines to app/etc/local.xml file (inside <config>...</config> tags):

Xml to Remove Estimate Shipping Cost Block Xml to Remove Estimate Shipping Cost Block

27. Optimize Shipping Rates Collection (M1 only)

When you change a payment method on a checkout page, Magento 1 recollects shipping rates.

Getting rates is a time-expensive procedure.

If your shipping costs don’t depend on payment method, you might want to disable that behaviour.

Copy app/code/core/Mage/Checkout/Model/Type/Onepage.php to app/code/local/Mage/Checkout/Model/Type/Onepage.php.

Open up app/code/local/Mage/Checkout/Model/Type/Onepage.php and find function savePayment.

Comment out the code block shown below:

Comment out Rates Collection on Payment Change Comment out Rates Collection on Payment Change

28 Disable Gift Message Extension (M1 only)

Less extensions - faster Magento.

If you don’t need Mage_GiftMessage, head over to System > Configuration > Advanced and disable it:

Disable Mage_GiftMessage Extension Disable Mage_GiftMessage Extension

29. Disable Configurable Swatches Observer for a Checkout Page (M1.9 only)

This is a Magento 1.9 optimization hack.

It also makes sense if most of your products are configurable ones.

It speeds up checkout process by 50ms per item. Suppose you added 10 products to a cart - that would be 0.5 sec off! Not bad.

Media Load Gallery Before Event Time Media Load Gallery Before Event Time

Here is what you need to do…

Copy app/code/core/Mage/ConfigurableSwatches/Model/Observer.php to app/code/local/Mage/ConfigurableSwatches/Model/Observer.php.

Open app/code/local/Mage/ConfigurableSwatches/Model/Observer.php and find function loadChildProductImagesOnMediaLoad.

Add the following line at the beginning of that function and make it look like this:

Change Function loadChildProductImagesOnMediaLoad Change Function loadChildProductImagesOnMediaLoad

30. Full Page Cache (FPC) Extension (M1 only)

FPC caches whole pages making time to first byte well under 0.5 seconds.

Magento 2 comes with full page cache functionality. Magento 1 doesn’t.

While many say caching ! = performance, I say,“Go get a decent FPC plugin right now!”

FPC is a Magento speed optimization extension that does make your visitors think your site is incredibly fast.

31. Upgrade to PHP7

Magento is powered by an interpreter engine called PHP.

PHP had a major upgrade not so long ago - the version 7.

PHP7 runs faster than the previous PHP5.

Ask your system administrator if you are using the latest release.

If not, upgrade to give your online shop a performance boost.

32. Make Varnish Your Caching Application

Varnish is a special server software that can cache and serve content super fast.

It is placed between users and a Magento site as shown below:

How Magento works with Varnish How Magento works with Varnish

Instructions for M1…

First, install Varnish on a server.

Second, use Nexcess Turpentine extension.

It is free and easy to set up. Here is an official github page with all Installation and Usage pages.

Instructions for M2

Magento 2 can use Varnish natively.

But…

You still have to install it on your server.

After you do that, enter host/port and other parameters at M2 Stores > Configuration > Advanced > System > Full Page Cache:

M2 Varnish Configuration M2 Varnish Configuration

On that page at the bottom you will see Export Configuration buttons.

M2 Varnish Export Configuration File M2 Varnish Export Configuration File

Export VLC file for your version of Varnish and ask your system administrator to upload it to the server.

You are almost done...

Now go and browse your website to see if it is fast enough.

33. Magento MySQL Optimization

This tip only makes sense if you are managing your own server.

If you are on a managed hosting plan (as you should be),go over to the next section.

First, collect DB statistic using this little perl script - mysqltuner.

It will tell you what needs to be done, right at the bottom:

Mysqltuner Recommendations Mysqltuner Recommendations

Go over to “Variables to adjust” part and set my.cnf configuration variables accordingly.

Where do you find my.cnf? It is usually at /etc/my.cnf.

34. Perform 3rd-party Extensions Audit

Well, it is the last step but it should have been the first one.

If you want to know how to increase magento website speed, this is what you should start with - a 3rd-party plugins audit.

It’s no surprise that custom extensions make Magento slower.

Not all of them but some and here is why…

On the one hand, Magento core was written by programming experts. There is little to no room for performance improvement in a stock installation.

On the other hand, various 3rd-party plugins are written by average coders at mostith no appreciation for performance benchmarks.

The rule of thumb here is to have as less custom modules as possible.

The ones you do have have to be inspected thoroughly.

Here is what I usually do:

  1. Disable extensions one by one

  2. Benchmark speed with and without an extension

  3. Find those that take most time to run

  4. Contact its vendor and let them patch

  5. If there is no patch, find an alternative or simple remove it

When my clients ask me, “how would I quickly speed up magento2?”

I always answer, “just remove all custom extensions.”

Bonus: Implement a Magento Site Speed Test

Include performance benchmarks into your workflow. Every time you add an extension from Magento, connect or roll out a new feature, see what impact it has on site speed. Does it slow Magento? Debug or go for another module.

A few tools that will help you answer the question “how to reduce page load time in magento ?” (free to use):

1. webpagetest.org – provides you with page-loading waterfall charts and tons of other useful information. Supports mobile browsers.

2. Google Chrome Timeline – helps you analyze frontend performance. Takes a little time to get use to, but once you are familiar with it, it gives you valuable insights into why your Magento is slow.

3. Google PageSpeed Insights – an online tool that tells you what to do to boost site performance. Work on suggestions by Google and improve Magento speed.

Does all these 34 tips seem too complex for you?

Try my magento speed optimization service.

I have experience. I have references.

  

Struggle with slow Magento! We can help! Fill out the form below to get a free quote.

 

Other articles you might be interested in:

  1. Magento 2 hardware requirements (Updated 2018)
  2. Magento 2 TTFB (Time To First Byte) Optimization
  3. Magento TTFB optimization to reduce time to first byte
  4. WooCommerce and Magento 2 - 1 million products benchmark
  5. Magento 2 and 1 Million Products

  

If you find this post interesting do not hesitate to sign up for our newsletter and join the 877 people who receive Magento news, tips and tricks regularly.

Thank You!

 

9 thoughts on “Speed up Magento 2 and 1 - The Ultimate Guide (Updated 2018)”
  • Daria
    Daria August 21, 2018 at 9:06 am

    Hi! Thank you for the useful information.

  • deep
    deep January 3, 2018 at 11:38 pm

    wow. awesome contents

  • Randy de Decker
    Randy de Decker November 11, 2017 at 4:28 am

    Good article that I've bookmarked. I've implemented a lot of these actions above, but good to know there are still some improvement points left.
    I agree with Steve that HHVM should not be used with M1. And a good FPC decreases load times substantially, but offcourse does not improve the uncached pages loadtime.

  • Fayyaz Khattak
    Fayyaz Khattak September 28, 2017 at 11:40 am

    Well, I have used Cloudways Magento Full Page Extension powered by Amasty to speed up the Magento performance. I avoided using heave theme and used trusted extensions to accomplish some tasks on my ecommerce store. The store now loads within 2 seconds, and I am delighted with the reviews of my customers about the performance of the store.

  • Alexander
    Alexander July 27, 2017 at 3:32 am

    Magento is an ecommerce heavy open source platform. It is a big problem for you when your magento store runs slowly and at that time you have to setup it properly.

  • Tej singh
    Tej singh May 30, 2017 at 4:35 am

    Tottaly agreed to all the above points foe increased magento page speed but one point we are forgetting is what happens if we clear cache in middle of the day when customers are actually hitting the site, best solution is to have cache warmer that quickly crawls and puts the page back under cache.

  • olivedev
    olivedev January 19, 2017 at 5:11 am

    Some great tips for optimizing Magento's speed. Few more things that you can do to tune the performance are: install Turpentine – Varnish Cache plugin and configure Memcached with Magento 2. You will notice a significant increase in speed.

  • Konstantin Gerasimov
    Konstantin Gerasimov October 25, 2016 at 3:41 am

    @Steve - thank you for your comment

    what did you mean by " I’d take care with infrastructure suggestions that are outside Magento’s requirements ( so no HHVM, > 5.4/5/6 on Magento 1.x and so on ). Don’t want to get sued!"?

    I run HHVM with magento 1.x with no problems

    master-slave setup for magento is a great way to speed things up - master for writes, slave for reads - magento supports separate reads/writes databases.

  • Steve Holdoway
    Steve Holdoway October 25, 2016 at 1:20 am

    Great to see a well thought out list rather than the usual regurgitated posts from a decade ago! However, I do disagree with a few of these, and have a few suggestions ( well, what do you expect from a grumpy old bugger like me! )...

    - If you split database and web server then you've not only added a new point of failure ( and potential performance problems ), but you now have to build up / tear down TCP connectivity to extract data from the database, rather than ( with a properly configured server ) just pick it out from local memory.

    - it's very unlikely that your site will ever become busy enough to require a master / slave database setup. Also remember that this will slow things down if you're not very careful indeed.

    - there are many more file types that can take advantage of browser caching.

    - domain sharding is pointless with use of a CDN... just hand the heavy lifting over to them and let them sort it out.


    Also...

    - what about http2?

    - I'd take care with infrastructure suggestions that are outside Magento's requirements ( so no HHVM, > 5.4/5/6 on Magento 1.x and so on ). Don't want to get sued!

    - tuning of the OS?

    - and finally what about caching!