Technical points related to Magento Performance considered by us while optimizing Magento for Speed
- Use of image sprites to reduce number of request
- Optimize images for size
- Remove unwanted css code and minify or reduce your css code
- Remove unwanted js code and minify or reduce your js code
- Specify Image Dimensions
- Use some webtest tool to analyse number of requests and other html related data for download time
- Make sure enable Flat Catalog
- Make sure enable Compiler Mode
- Merge css and js (Used Fooman Speedster Module)
- Delete additional stores if not in use
- As per requirement, Log should be minimized according to number of days
- Disable Log Settings in magento
- Remove Admin notification module
- Improve magento database Log Cleaning via admin
- Enable Gzip compression in .htaccess
- Use nginx
- Use of APC
- Use query cache
- Use Apache mod_expires
- Use a Content Delivery Network (CDN)
- Enable Apache KeepAlives
- Load cache on RAM if memory permits
- Reduce hard disc file reads and try reads from RAM as this is faster
- Upgrade PHP version to above 5.3
- Session to be on RAM
- Make sure cron is run so as to clean logs stored in data base
- Your cron file should be run in specific hours
- Disable the PHP open_basedir directive
- Eliminate directory structure scans for .htaccess files
- Use FPC.
- Remove all modules not in use by removing there .xml file
- If possible, use Ajax
- Don’t use CMS blocks
- Do not use many various external sources.
- Abbreviate number of searchable attributes as these result in columns in flat catalog table and will slow down your search.
- Use of Solr search. It already exists with EE version but it can be installed with CE.
- Minimize customer group as suggested in comment.
- Make sure your css code check through W3 validator because errors slow down the browser.
- Use of getChildHtml (‘childName’) is recommended as this will cache block against direct use of block code in .phtml file.
- Remove unwanted blocks. (Number of blocks are executed that are not used or displayed.)
- If using FPC make sure your containers are cached and repeat request for container is delivered via cache. Improper placeholder definition results in container cache not being used but each time new container content getting generated.
- Analyze page blocks and variables and if possible add those variables/blocks to cache.
- Remove directory structure scans for .htaccess files.
- Use Google page speed firefox extension like Yslow.
- If on EE make sure that most pages are loaded without application initialization. If one container needs application initialization its going to effect execution speed.
1] Don’t use CMS block
It takes more time than Magento block.
Q. What is a FPC(Fullpagecache)?
A Full Page Cache is a very important technique which allows us copy content from web by storing the data to a temporary container to help reduce memory.
Q. Which pages are cached by Full Page Cache?
A There are three types of pages which can be cached by Full Page Cache.
Category View pages
Product View Pages
CMS Pages“By using Full page cache, improve your Magento performance, optimization, and page speeds."
3] Remove unwanted blocks. (Number of blocks are executed that are not used or displayed)
a) First check XML for blocks present in default handle and if those blocks not present in particular page then transferred from default handle to its particular handle. b) Unwanted code is executed and decrease the speed of magento website. Hence remove unwanted blocks from specific page.
Q. How to remove block from specific handle through xml file?
A customer_account_login remove name=”.compare.sidebar” –product compare– customer_account_login”
4] Use of FPC
If using FPC make sure your containers are cached and repeat request for container is delivered via cache. Improper placeholder definition results in container cache not being used but each time new container content getting generated. Magento Enterprise consists of number of useful numbers of features. In which, one is very important it may increase your store performance. It is a full page cache. It present in Magento Admin
System → Configuration → Cache Management
Full Page Cache is more useful mechanism that permits copy data by storing the page content to a temporary container to help reduce memory and database load.
Full page cahe is a way for Magento to load content for a user without having to fully initialize the application.
Make sure your containers are cached if we using Full Page Cache and check repeat request for container is delivered via cache. Containers create from placeholders.
Hence, incorrect placeholder results in container cache not used but each time new container content getting generated then create unwanted data or cache and decrease the magento website speed.
How to check your container cached or not? (fully initialize application or not)
Each container consists of two important methods applyWithoutApp and applyInApp
5] Use of getChildHtml (‘childName’)
Use of getChildHtml (‘childName’) is recommended as this will cache block against direct use of block code in .phtml file:
getChildHtml function is used to get block code. We can not imagine that the block is defined in the layout file that it will be rendered.
Either the toHtml() needs to explicitly render the child blocks, or the phtml assigned to the block must render the child blocks via thegetChildHtml()function
You will want to be conscious of is the $useCache parameter.
If the $useCache parameter is true, Magento will check this internal property for an existing generated output block before calling the toHtml method on the child block.
Class Name: Mage_Core_Block_Abstract
6] Check CSS code through W3 validator
Make sure your CSS code check through w3 validator because errors down the browser Why you should validate your CSS code? CSS validation express that there are number of points why we should validate our CSS code.
1] It helps future consistency: You may be able to create a web page that takes to work on your favourite browser, your page may contain CSS errors that do not show up with that browser due to an existing errors.
2] Search Engine Visibility: When there are errors in a web page, browsers typically try to good in different ways.
One way to improve your Web site’s Search Engine results is to validate your code.
Important URL for validate CSS code: http://www.css-validator.org/
7] Make your output W3C compliant
Make your website output compliant then validating code. One way to improve your website search engine results is to validate your code. W3C is an international consortium.
W3C stands for World Wide Web Consortium (W3C).
W3C ValidatorTool: http://www.w3.org/QA/Tools/#validators
8] Do not use many various external sources
Do not use many various external sources (for images (twitter/facebook)) because it takes extra time and you
create an extra dependency on third party server for your site to load properly. Hence it takes more time to load
your pages and decrease the speed performance for Magento website.
9] Use of Solr search
It already exists with EE version but it can be installed with CE
10] Use Google page speed firefox plugin/addon like Yslow
Yslow is a Firefox plugin. It is used to check page speed.
YSlow explores web pages and suggests ways to improve
their performance based on a set of rules for high performance web pages.
Yslow add-on install from following URL: https://addons.mozilla.org/en-US/firefox/addon/yslow/
Yslow website URL: http://yslow.org/
11] Abbreviate number of searchable attributes as these result in columns in flat catalog table and will slow down your search.
Only those attributes front-end properties set to ‘YES’ that you are actually to use.
Set all other to ‘NO’. Also do not use in quick search, advanced search etc.
Go to Magento Admin Panel:
Catalog → Attributes → Manage Attributes → Frontend Properties
1] Enable Gzip Compression in .htaccess:
a) Shrinkage of our Html and css code with Gzip, it saves file size.
b) This means that, it takes less time to load your pages. This is important for optimization.
c) If Gzip enabled on your server then it receives the Gzip file which is very small file it takes less time.
d) How to set Gzip?
There are so many ways to set Gzip setting depends on our server.
There are so many ways of making Magneto run faster. The best one is to enable GZip
compression by changing in .htaccess file.
2] Use nginx:
nginx is a free server. When we used nginx server then you could speed up magento scripts. Therefore, we used nginx server and speed up our Magento site. It is used for memory.
3] Use Magento CDN:
CDN : Content Delivery Network
Que: What is a CDN?
Ans: CDN is a network of server which transfers content from site to the user.
Que: Why used CDN?
4] Use of APC:
APC: Alternative PHP cache
Que: What is a APC?
Ans: APC is an opcode cache for PHP. It is a structure for using cache and optimizing PHP code.
5] Use Query Cache:
This is another thing for Magento Speed Optimization tip is use Query Cache. Improving magento speed is more important for Magento Developers.
There are two types of caching which you can use to optimize the magento site.
a) Disk Cache
b) Database Cache
Benefit of Query cache: The database is fast as compared to disk so it is useful and important for increasing the performance of Magento.
Important-URL: http://www.crucialwebhost.com/kb/improving-magento-performance-with-mysql-query-cache/6] Enable KeepAlive:
When browser needs to show a webpage it must first get the HTML file. After that, it will check and read the HTML file request more files related to css and images etc. When KeepAlive is not enabled this can add a lots of time to load a webpage.
Magento Admin Configuration
1] Enable Flat Catalog
Enable Flat Catalog Category and Product:
There are following two options which you can enable or disable in the magento backend.
a) Flat Catalog Category
b) Flat Catalog Product
Why Enable Flat Catalog?
In Magento, all product and category connected data is stored in the database. The database consists of collection of tables. There are number of tables. When magento found number of tables for different data that’s scattered, it can becomes slow. Hence, Enable Flat Catalog Category and Product which reducing the response time.
2] Enable Compiler Mode
Go to Magento admin: System > Tools > Compilation
3] Merging css and js (Used Fooman Speedster Module)
1) How to reduce HTTP requests for your site?
site makes to the server and will have a nice effect on speed.
Go to Magento admin : System > Configuration > Developer > JS settings and select
“Yes” for “Merge JS Files”.
Enable CSS file merging:
Combining all CSS files into one will reduce load time and increase speed.
You can combine all CSS files into one via the Magento admin:
Go to Magento admin : System > Configuration > Developer > CSS settings and select
“Yes” for “Merge CSS Files”.
You can also using an extensions to do this like the Fooman Speedster Extension, which works best for you.
URL: Fooman Speedster
4] Disable Log Settings in magento.
How to disable the logs settings?
Go to Magento Admin: The settings are under System --> Configuration >
Developer --> Log Settings.
5] Remove Admin notification module
Q How to remove admin-notification module?
There are two ways to remove admin-notification module.
A) Go to Magento Admin: System → Configuration → Advanced → Advanced → Disable
After that, Simply set Mage_AdminNotification to Disable. Please check following screenshot.
B) We can off the module from the modules XML file. Check following screenshot.
6] Remove all modules not in use by removing there .xml file
We can disable the module from there modules XML file. Check following screenshot.
7] Improve magento database Log Cleaning via admin
1] In Magento Admin Panel , Go to System → Configuration
2] In the left Menu Click Advanced → System
3] Log Cleaning, change “Enable Log Cleaning” to Yes and configure time.
4] Click Save Config.
Magento Template Related
In our series of Speed Optimization Related blogs, we will discuss on configuration,template,server points that will helps speed up your Magento site, Speed is important for your site.
Speeding up Magento sites takes a long list to perform.You can go through the following tips for Magento Speed Optimization.
1] Use image sprites to reduce number of request and use of image sprites:
Q) What is a sprite?
A) A sprite consists of multiple images into a single image.
Q) Why use sprite image?
A) Using sprites should decrease a number of HTTP requests made to your site and improve the site speed.
2] Optimize images for size:
Decrease the load times of pages by loading appropriately sized images.
3] Remove unwanted code and minify or reduce your css code:
Clean-css and minify css is a fast and efficient.It helps speed up magento site.
4] Specify Image Dimensions:
How to specify image dimension:
Following image without dimensions.
Following image with dimensions.
Why specify image dimension : Specifying the height and width to your images can really help your webpages load faster and look better while they are loading. Hence, Specifying a width and height for all images and imporove the speed of magento website.
How to apply lazyloader for images:
Important URL: http://jquery.eisbehr.de/lazy/
6] Use some webtest tool to analyse number of requests and other html related data for download time:
Test your site with some following tools:
You can test your site using following available tools
Configuration and Template Points
In our series of Magento Speed Optimization blog, we will discuss on configuration points that will helps speed up your Magento site.
1] Enable Flat Categories and Products:
There are following two options which you can enable or disable in the Magento backend.
a) Flat Catalog Category
b) Flat Catalog Product
It is recommended that you enable this feature and here is why.
All the category and product related information is saved in the database in Magento. The database consists of a collection of tables. There are numbers of tables.
So when Magento has to search multiple tables for information that’s spread out, it can become slow.
Therefore, enabling Use Flat Catalog Category and Use Flat Catalog Product will take the information that’s spread out and flatten it into one table usually reducing the response time.
2] Enable Magento Cache:
Magento consists of internal and external cache.
a) Internal Cache:
Go to Magento admin: System > Cache Management
Go to Magento admin: System > Configuration > ADVANCED > System
3] Combine CSS and JS in magento:
Go to magento admin : System > Configuration > ADVANCED > Developer
4] Magento Compilation:
Go to magento admin : System > Tools > Compilation
When your site get high traffic, this cause a big trouble.
In all cases, you should config your Magento Log cleaning.
6] Disable Magento logging:
Disable the Magento Log: System -> Configuration -> Advanced -> Developer -> Log Settings (default is disabled).
7] Test your site with some following tools:
You can test your site using following avaliable tools
1] Optimize all your (template) images and optimizes images for size:
a) Crop the white space using your image editor.
b) Use CSS image Sprites.
An image sprite is a collection of images that are put into a single image and called via specific CSS classes to that page in order to reduce the load time of the page, as well as the amount of HTTP requests need to be sent to the server. This also has the benefit of reducing the size of your images and decreasing page load times.
2] Remove unwanted code and minify or reduce your css code:
3] Specify Image Dimensions:
Specifying a width and height for all images.
Few Tricks on Magento Speed Optimization
A website sells more if its speed is good. A slow website will loose customers as present customers do not have time or patience to wait for slow page loading.
With reference to a site built on Magento, speed related steps are bigger concern. Magento uses EAV concept which allows and gives Magento lots of flexibility but this also means in lots of DB tables. Imagine one product data going into more then 40 tables.
Magento team was aware of this shortcoming so they have added indexing and flat table concept. Also they have a good caching concept and for enterprise version. They have full page caching.
Magento development and implementation team should know how to use these concept with proper configuration, standard template, customization with FPC and cache usage in mind.
Also at HTML render make sure that time is less. This can be achieved by reducing number of request (Use of image sprite, merge .js files,merge .css files)
Also minimize 3rd party request (This needs DNS resolution) and if needed make sure these are called after document has been downloaded.
A well optimized site should on dedicated then 3 seconds for complete download (less than 0.8 second to load HTML)
Contact us and we will give tentative estimate that your site page should need to load.
Use Google page speed tool or yslow to check Magento Site Speed.
Hardware and server configuration
In our series of Magento speed optimization blogs. In this blog, we will discuss on hardware and server configuration.
-Nginx is recommended over apache. Though some experts debate they can make apache run faster than nginx. If traffic is less than certain defined values.This too cant be achieved without lots of apache tuning where as nginx by default is a good candidate.
-APC, memcache, Redis
-Cache to be loaded on RAM.
-Varnish installation is recommended
– Install and use Solr search. Highly recommended for enterprise version.
-gzip to be enabled.
-Keep Alive to be set to true.
-Set expire header value.
My SQL Queries
In Our servies of blogs related to Magento speed optimization. In this blog, we will discuss about MySQL queries and its role in site speed.
we have optimized many Magento websites. What we see is that if Magento templating and coding or extension selection is not done properly then site ends up executing 2000 plus queries per page. A well done Magento site page without FPC should not take more then 300 queries and with FPC not more than 100 queries.
To achieve this developers should give thoughts to make sure blocks are cached. In case of FPC they should make sure there are very few containers and containers should be delivered most of time without initializing application.
MySQL queries are not a big issue if there is less traffic but as traffic increases these queries might result in lots of load on MySQL server which in turn might result in slower MySQL responses and higher page load time.
It has been observed that under such circumstances development companies request website owners to add additional server & do load balancing or they request website owners to upgrade hosting plans.
Contact us and we will do a free analysis on this point for your site. In 90% case that we have reviewed. We have found that there is a good scope for optimization.
Magento Speed Optimization -Configuration points
In our series of Magento Speed Optimization blog, we will discuss on configuration points that will helps speed up your Magento site.
-Use Flat Catalog for products:- Yes
-Use Flat Catalog for category:- Yes
-Enable all options of cache.
-Log cleaning to be switched On. Also reduce number of days that you want logs to be saved for.
-Compiler mode to be switched on.
-Merge js and CSS.
-Delete Catalog rules not in use.
-Delete customer groups not in use.
-Delete stores/store views not in use.
-Delete language not in use.
-Disable module output not in use.
-Disable exception and system logs.
Magento Speed Optimization – Modules / Extension
In our series of Magento Speed Optimization blog. In this blog, we will discuss about extension and effect on speed.
In magento, you can disable module output via admin configuration. But this does stops modules from getting executed.
If you want to totally remove a module from Magento execution. You need to delete or remove .XML for that module. This is placed in app/etc folder. Make sure if XML file is renamed that extension is not .XML as Magento will read all files with .XML extension.
Some of the community modules are not developed with block caching in mind or these modules load objects that are already loaded. So we recommend not to just install every module without making sure they are not going to effect a lot on resource consumption.
Determining whether upgrade is needed
In this series of Magento Speed Optimization. Here in this blog, we will discuss on steps to determines whether upgrade is needed.
If you are planning to upgrade your hosting check the following :-
-Using google speed page tool check your page score.
-Check how much time for first byte.
-Check total number of request.
-Check how many .js and .css
-Check number of MySQL queries per pages
-Check peak memory and peak load
If your MySQL queries are more than 300 per page request than before upgrading hosting package optimize your code. If it is less than 300 and this first byte time is more than 1.25 seconds with cache enabled then its time to upgrade your hosting.
If still there is some confusion then contact Us and we will respond and suggest.
Magento Speed Optimization- Top Coding Tips
Avoid use of CMS blocks and use XML created blocks wherever possible. This will result in lesser control to admin but will speed up your site. CMS blocks take more time.
When ever writing block code make sure cache concept is in place.
Avoid loading complete module. Check registry for object needed and if not there then only make model and resource calls.
Magento uses EAV concept so consumes lots of resources. To overcome this if Magento standard practices & tips are applied Magento is fast and can run smoothly on VPS Server or some low level hosting plans.
We have optimized more than 20 Magento website. Proper application ofConfiguration Indexing Cache FPC Standard Templating Html based optimization
is what is needed to optimize Magento site.
Also check following link : http://stackoverflow.com/questions/9216743/tweaking-magento-for-performance/15458875#15458875.
We do optimize at following levels:
1) Configuration : By checking Flat Catalog settings and other configuration parameters so as to reduce required resources.
5) Analyzing site from html perspective and reducing html related request and download time.
6) Use of Solr to move search from Mysql to Solr search which in turn will reduce Mysql server load.
7) Standard templating so most of the blocks are cached and fewer sql queries are needed.
Here is indepth explanation:
Make sure flat catalog is used.
compiler mode to be set on.
Merge css and js(Fooman Speedster ).
Your cron should be run in offpeak hours.
Delete additional stores if not in use.
Delete cart rules if not in use.
Minimize customer group as suggested in comment.
Remove staging stores if on EE.
Use of Solr in EE in highly recommended for all features support provided by EE. Bypassing solar and loading on Mysql is no recommended.
Use image sprites to reduce number of request.
optimize image for size.
Use Ajax( Lazy loading of images) where ever possible.
Make your output W3C compliant
Use of image sprites
Use some web test tool to analyse number of requests and other html related parameters responsible for download time and act accordingly.
Use query cache but avoid size greater then 64 MB.
Session to be on Ram
Use of APC recommended
Enable Gzip Compression in .htaccess
Load cache on RAM if memory permits.
Reduce hard disc file reads and try reads from ram as this is faster.
Instead of using Apache use nginx or litespeed.
Use Apache mod_expires and be sure to set how long files should be cached.In case you are on Apache server.
Use a Content Delivery Network (CDN).
Enable Apache KeepAlives.
Make sure cron is run so as to clean logs stored in data base.
Number of days log should be minimized as per requirement.
Upgrade PHP version to above 5.3
Remove all modules not in use by removing there xml.Just disabling will not do.
Use Ajax( Lazy loading of images) where ever possible.
CMS blocks take more time then a magento block so unless you want a block to be modified do not use CMS blocks.
Do not use collection count use collection getSize to get what is the collection size.
Minimize number of searchable attributes as these result in columns in flat catalog table and will slow down your search.
If on EE make sure that most pages are delivered without application initialization.Even if one container needs application initialization its going to effect execution speed as apart form URL rewrites most of the other code will get executed.
Check XML for blocks placed in default handle and if those blocks not on specific page then move those XML values from default handle to specific handles.It has been observed that lots of blocks are executed that are not displayed.
If using FPC make sure your containers are cached and repeat request for container is delivered via cache.Improper placeholder definition results in container cache not being used but each time new container content getting generated.
Analyze page blocks and variables and if possible add those variables/blocks to cache.
Use of Solr for search and layered navigation is recommended.
Check XML for blocks placed in default handle and if those blocks not on specific page then move those XML values from default handle to specific handles(using Local.xml).It has been observed that lots of blocks are executed that are not displayed.
Use of getChildHtml(‘childName’) is recommended as this will cache block against direct use of block code in .phtml file.
Might help but not recommended:
Switch off Logs writing in Magento.
Remove Admin notification module.