As per Benchmark Testing, that makes the comparison between out-of-the-box supported and recommended configurations for Magento 2.0 which proved that Magento 2.0 is considered as the greater platform than Magento 1.x keeping in mind all metrics and use cases. Magento 2.0 will never disappoint you when you talk about a result.
Now, it’s time to understand How Magento 2 Performance is optimized?
A normal Ecommerce page takes more than 3 seconds to load a product page. Now think for a minute that your customer can be annoyed if he needs to browse through five similar pages on your website? Indeed they will never be patient to wait for the delay. Hence keep the below steps in mind to give them the best experience of your site.
Magento 2 Performance Optimization Step-by-step:
Before following all steps, let us give you bonus advice in advance.
First, check your website score in Google PageSpeed Tools
If your score is low, make it high by following Google guidelines.
Step 1: Enable Flat Categories and Products
Magento 2 has created a great influence by its ability of database loading. In the configuration, you need to enable Flat Catalog to speed up that. Flat Catalog allows offloading the number of the database once there is any request for showing the product. Parallelly, the MySQL query complexity will reduce.
Now, Go to backend, Stores > Configuration > Catalog > Catalog > Storefront,
Choose Yes in Use Flat Catalog Category field.
Step 2: Merge CSS and JS Files
In this step, you need to follow is merging and minifying CSS and Javascript files, which means making the web page as light as possible for the fast loading that puts Magento 2 into production mode.
1 |
./bin/magento deploy:mode:set production |
Javascript File
Go to backend, Stores -> Configuration > Advanced > Developer > JavaScript Settings
Set Merge JavaScript Files to Yes
Set Minify JavaScript Files to Yes
CSS File
Go to backend, Stores > Configuration > Advanced > Developer > CSS Settings
Set Merge CSS Files to Yes
Set Minify CSS Files to Yes
When finished, click on Save Config and flush cache to activate the change.
Step 3: Content Delivery Network
Content Delivery Network (CDN) is a special system that can connect all cache servers also it also supports geographical proximity by taking over the delivering web content and fasten the page loading.
Follow our guide to set up CDN for Magento 2 stores.
Go to backend, Stores -> Configuration > General > Web > Base URLs (Secure)
Step 4: Caching
In the backend go to the System > Cache Management.
Here, you will find plenty of caching options to flush your Magento 2 cache.
Click on Enable and then submit the options which you want.
Step 5: Image Optimization
The image plays an important factor to make your Magento 2 store’s performance more vivid. However, uploading the heavy size image on your site is one of the crucial reasons for the overload page. So, you have to compress the image before submitting any image. Using a JPEG format for Product images, and PNG or SVG for the layout as well as the logo is the best solution.
Step 6: Enable Compression
Follow below resources to enable compression by Google’s offer.
Now let’s change nginx compression directives from:
gzip_types: text/plain application/x-javascript text/javascript text/xml text/css image/x-icon image/bmp image/png image/gif; to gzip_types: *;
Step 7: Reduce Server Response Time
Your site’s response time is quite good with approximately 0.5s all thanks to Magento 2 built-in cache functionality. But as Google expects it is not the ideal time. Due to that, Magento 2 provides support to Full Page Cache via Varnish natively.
Now, let’s set up Varnish to get the first byte around 0.1-0.2s.
Go to backend, Stores > Configuration > Advanced > System > Full Page Cache,
Transfer Caching Application to Varnish Cache.
Open the Varnish Configuration section, complete the settings:
Step 8: Magento Updates
Remember to update your Magento 2 store. Mage monkeys team will try their best to help you optimize the site performance.
The result after updating your store from older version to latest version.
Performance Toolkit (Optional)
Installation
jMeter:
– go to http://jmeter.apache.org/download_jmeter.cgi and download jMeter in Binary section (pay you the attention that Java 6 or later is required) – unzip the archive
Plugins (only if you want to additional reports (like graphs)):
– go to http://jmeter-plugins.org/downloads/all/ and download JMeterPlugins-Standard and JMeterPlugins-Extras
– unzip them to the appropriate ext directory of your jMeter instance.
– Additional reports can now be added via GUI.
Usage
Before running the jMeter tests for the first time, you will need to first use bin/Magento setup:performance:generate-fixtures command to generate the test data.
Run via console
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Scenario can accept parameters that are described bellow in format <parameter_name:default_value>: <host:localhost> URL component 'host' of application being tested (URL or IP). Default is 'localhost'. <base_path:/> Base path for tested site. Default is '/'. <report_save_path:./> Path where reports will be saved. Reports will be saved in current working directory by default. Default is './'. <ramp_period:300> Ramp period (seconds). Period the request will be distributed within. Default is '300'. <orders:0> Number of orders in the period specified in the current allocation. If <orders> is specified, the <users> parameter will be recalculated. Default is '0'. <users:100> Number of concurrent users. Recommended amount is 100. Minimal amount is 10. Default is '100'. <view_product_add_to_cart_percent:62/> Percentage of users that will only reach the add to cart stage. Default is '62'. <view_catalog_percent:30/> Percentage of users that will only reach the view catalog stage. Default is '30'. <guest_checkout_percent:4/> Percentage of users that will reach the guest checkout stage. Default is '4'. <customer_checkout_percent:4/> Percentage of users that will reach the (logged-in) customer checkout stage. Default is '4'. <loops:1/> Number of loops to run. Default is '1'. <admin_path:admin/> Admin backend path. Default is 'admin'. <admin-user:admin/> Admin backend user. Default is 'admin'. <admin-password:123123q/> Admin backend password. Default is '123123q'. <think_time_deviation:1000> Deviation (ms) for "think time" emulation. Default is '1000'. <think_time_delay_offset:2000> Constant delay offset (ms) for "think time" emulation. Default is '2000'. Necessary parameters must be passed to [command line](https://magemonkeys.com/magento-2-command-line-interface-cli.html) with "J" prefix: "-J<parameter_name>=<parameter_value>" |
Example:
1 2 3 |
> cd /directory_of_jMeter/bin/ > jmeter -n -t /path_to_benchmark_file/benchmark.jmx -Jhost=magento2.dev -Jbase_path=/ -Jusers=100 -Jramp_period=300 -Jreport_save_path=./ |
Run via GUI
Open jMeter/bin directory and run jmeter.bat
Click in menu File -> Open (Ctrl+O) and select file; or drag and drop benchmark.jmx file in opened GUI.
On the first tab ‘Test Toolkit’ you can change ‘User Defined variables’ like as , , , , .
For running script click “Start” (green arrow in the top menu).
Results of running (Report types)
When you run via GUI you can see the result of working in the left panel. Choose the corresponding report.
After running the script via console report will be created in the path that has been specified.
Threads
jMeter script consists of five threads. Setup thread and four user threads.
The percentage ratio between threads is as follows:
Magento 2 Performance Optimization Tools:
If you are looking for professional shortcut tools to cut down the performance time conveniently, Mage Monkeys is happy to introduce one useful extension for both Magento 1 & 2 stores.
WHAT ARE CORE WEB VITALS? Google’s aim is to make...
Google’s core web vitals valuates different metrics related to the...
Is your eCommerce store facing some page speed issues? If...
If 'YES', then it is time you consider the matter...
It's been observed by numerous eCommerce store owners that after...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.