16

I've been asked to try and find a solution for the slow load time of our Magento site. I ran a Yslow test and the biggest offenders seem to be

  • Make fewer HTTP requests
  • Use a CDN
  • Add Expires Headers
  • Put Javascript at the Bottom
  • Minify jS and CSS
  • Configure ET Tags
  • Reduce DNS lookups
  • Avoid AlphaImageLoader Filter

As an E-Commerce manager I am looking for some advice as to what I can do from my role within the Magento admin, webmaster tools, etc. and what I can instruct a developer to do get our site up to compliance and noticeably speedier.

I've also been looking at a plugin called GTMetrix that seems to do a lot of this for you within the admin (combine CSS sheets, optimize images, etc), does anyone have any experience with this? I usually try to avoid too many extensions that reach so deep into essential functions but seems like might be a solution. http://gtmetrix.com/magento-optimization-guide.html

Your advice would be much appreciated, as I am having a hard time knowing where to start to have the best impact.

Thanks in advance.

enter image description here

enter image description here

27

(copied from my own blog at https://www.gui.do/post/101-ways-to-speed-up-your-magento-e-commerce-website)

A) Hosting environment/ General tips

  1. Get a dedicated server.
  2. Host your site in the country where your customers are.
  3. Don't host files on your web server that you do not use, large or small.
  4. Goto MySQL Admin and select all the tables and repair and then optimize them.
  5. Use a PHP accelerator like APC, ZendOptimizer+ or Xcache.
  6. Only install necessary Apache modules.
  7. Use Apache mod_expires and be sure to set how long files should be cached. You could use the example below for your Apache virtualhost config: # Turn on Expires and set default to 0 ExpiresActive On ExpiresDefault A0 # Set up caching on media files for 1 year (forever?) ExpiresDefault A29030400 Header append Cache-Control "public" # Set up caching on media files for 2 weeks ExpiresDefault A1209600 Header append Cache-Control "public" # Set up 1 week caching on commonly updated files ExpiresDefault A604800 Header append Cache-Control "proxy-revalidate" # Force no caching for dynamic files ExpiresActive Off Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" Header set Pragma "no-cache"
  8. Enable Gzip Compression in htaccess.
  9. Compress output, use zlib.output_compression or mod_deflate.
  10. Use a Content Delivery Network (CDN) for parallel transfer of static content. There is a Magento extension that can help you do this with category and product images: the One Pica Image CDN. But... (see next tip).
  11. Don't use too many different external sources (for images, iframes, (twitter/facebook)feeds etc.) because every DNS lookup takes extra time and you create an extra dependancy (on some 3rd party server) for your site to load properly.
  12. Enable Apache KeepAlives: Make sure your Apache configuration has KeepAlives enabled. KeepAlives are a trick where multiple HTTP requests can be funneled through a single TCP connection. The setup of each TCP connection incurs additional time, this can significantly reduce the time it takes to download all the files (HTML, JavaScript, images) for a website. More info  at Apache.org. Be carefull though, I've heard from some that this create (a lot of) extra load on the server and might crash the server on high traffic moments!
  13. Minimize redirects.
  14. Make your output W3C compliant. Errors slow down the browser.
  15. Swap Apache for NginX or Litespeed. If this isn’t an option, then go for Zend Server (ideally the non-CE version so you can use full page caching).
  16. Turn off or at least reduce web server logging (reduces disk writes).
    • Disable Access Time Logging. Magento Wiki: For Linux servers, if you have access-time logging enabled on any of your mysql, web server or cache partitions, try turning it off for a performance boost. If you’re using ext3 or reiserfs there may be faster journal write methods you can use. For more info see Linux.com.
  17. Compile MySQL from source instead of your OS’s package manager.
  18. Always upgrade to the latest Magento version. Not only will you get more features and bug- and security fixes, but with every update Magento performs better.
  19. Query Cach size: Magento Blog: Modify the configuration for your MySQL server to take better advantage of your server’s RAM. Most Linux distributions provide a conservative MySQL package out of the box to ensure it will run on a wide array of hardware configurations. If you have ample RAM (eg, 1gb or more), then you may want to try tweaking the configuration. An example my.cnf is below, though you will want to consult the MySQL documentation for a complete list of configuration directives and recommended settings.
  20. set 'php_value memory_limit 128M' in your php configuration or add it to your .htaccess file to ensure you don't run out of memory.
  21. Use a memory-based filesystem for dynamic data. If you store dynamic data (var/cache, var/session) on RAMdisk or tmpfs, the disk I/O is decreased.
  22. Change realpath_cache_size in php.ini.
    realpath_cache_size=1M (careful, this is per apache process) realpath_cache_ttl=86400 (ok for production site) 
  23. Memcache (for the hardcore) is documented in http://www.magentocommerce.com/boards/viewthread/9037/ and more tips from http://alexle.net/archives/275 to get you up and running.
  24. Disable the PHP open_basedir directive. Read this.
  25. Eliminate directory structure scans for .htaccess files.
  26. Recommended innodb_buffer_pool_size.
    • Combined web and db server, 6 GB RAM:  2-3 GB
    • Dedicated database server, 6GB RAM: 5 GB
    • Dedicated database server, 12 GB RAM: 10 GB
  27. Query Cach: query_cache_size: 64MB, query_cache_limit: 2MB
  28. Use sa seperate backend server to handle admin users, process backend activity (cron), pre generate full page caching and to handle media queries.
  29. Use multiple web nodes (frontend servers) to handle browsing and checkout.
  30. Use Varnish reverse proxy caching, Magento explanation by @alistairstead: Varnish your Magento store, make it fly!.
  31. If you have a popular site that is heavily crawled by searchengines, you can save some resources by tweaking your robots.txt.
  32. Try some of these cache extensions:
    • http://www.artio.net/magento-extensions/m-turbo-accelerator
    • http://www.aitoc.com/en/magento_booster.html
    • http://www.tinybrick.com/magento-modules/performance.html/
  33. Install the Yireo DisableLog addon. It prevents Magento writing tons of stuff to your database which is useless when you're already using something like Google Analytics.

B) Template

  1. Optimize all your (template) images- Most if not all should be at least below 10kb.
    • Crop the white space using your image editor.
    • Use PNG8 Files or GIF files rather than Jpegs and don't use transparency (depending on how many colors you use and how large the image is, but try for yourself).
    • Scale images: make images in the dimensions you need and not resizing them in the editor.
    • Use image compression (you can use smush.it to do it for you).
    • Use CSS Sprites, there even are CSS Sprite Generators.
  2. Minify your Css, remove unused code.
  3. Minimize Javascript use.
  4. Use a lightweight template as a basis for your template. For example: the Yoast Blank SEO theme.
  5. Specify Image dimensions.
  6. Use Block cache and HTML output in your extensions.
  7. Apply Javascript Lazy Loader for prototype.

C) Magento configuration

  1. Uninstall any extensions that you don't actually use.
  2. Disable modules that you don't use: System -> Configuration -> Advanced -> Advanced. ![enter image description here][1]
  3. Enable all Magento Caches: System -> Cache Management.  
  4. Use an offsite Stats Tracker like Google Analytics and not an onsite one. Most of this will use Javascript, host the Javascript yourself.
  5. Combine Javascript and Combine CSS files: System ->Configuration ->Advanced ->Developer -> 'Javascript settings' and 'CSS Settings'. You can also consider using an extensions to do this like the Fooman Speedster extension, whichever works best for you.
  6. Try some of the Magento performance extensions.
  7. Enable the Magento Flat Catalog, only helpful for very large catalogs to feel the improvements.
  8. Don't use layered navigation if you don't really need it, it's resource intensive.
  9. Use Magento's Compilation feature. It's reported to give you a 25%-50% performance boost: System > Tools > Compilation. Edit: Yoav Kutner (Magento CTO) let me know that "in later versions since we optimized the catalog EAV, Magento Compilation is not really needed if you have byte code caching and if it is configured correctly".
  10. Use the correct session storage, choose file system or database (during setup). Most installations should use "file system" because it's faster and doesn't cause the database to grow. But if your site will run on multiple servers, you should select "database" so that a user's session data is available regardless of which server his/her request is served from. More info about this from Ashley Schroder at Magebase.com.
  11. Limit the number of products on a product overview page.
  12. Set only those attribute frontend properties to 'Yes' that you're actually going to use. Set all other to 'No'. Don't use in quick search, advanced search compare, etc etc.: Catalog -> Attributes -> Manage Atributes -> Frontend Properties.  
  13. Disable the Magento log: System -> Configuration -> Advanced -> Developer -> Log Settings (default is disabled).  

Enterprise only tip:

  • Disable Enterprise_CatalogEvent. Go to Admin -> System -> Configuration -> Catalog -> Catalog Events. Then you want to turn off the settings for "Enable Catalog Events Functionality" and "Enable Catalog Event Widget".
  • Enable Solr search, it's quicker compared to the default setup, especially when you have lots of products (>10k).
  • Enable Full Page Caching.

D) Speed testing, analysing, monitoring

  1. Test your Magento site with Magento Speed Test (by Ashley Schroder)
  2. Run your site through websiteoptimization.com.
  3. Use Google Page Speed Firefox extension or Yahoo Yslow for some tips from Google and Yahoo.
  4. Implement Google Speed measurements in Analytics: Measure Page Load Time with Site Speed Analytics Report
  5. Speed monitoring and downtime alerts.
    • Mon.itor.us
    • Pingdom

Bonus Tips

(because it doesn't actually speed up the frontend but only the backend):

  • Use K-Meleon if you are on Windows for your general Admin work. It renders Magento’s heavy JS back-end significantly faster than any other browser.
  • Use the GoogleGears extension from Yireo.com to cache static files locally.
  • Use a local pc/mac application to manage Magento (like mag-manager.com).

I do realize that you probably can't use all of the above tips but it's not about using them all, and sometimes you just make the choice to give a functionality a priority over performance and that's OK. If you can only apply some of them you will still increase speed and gain in user experience. And remember: because speed depends on many variables, some of the tips might not have an impact on your website at all while others can have a huge impact. So always test the impact of every step you take and take actions accordingly.

| improve this answer | |
4
  1. Images - I have seen many cases where the person uploading images (products, CMS pages, etc) is not trained in how to optimize image sizes. There are plenty of articles available online, but a lot of it is just common sense.

    • Don't use images for text.
    • Use JPEG/GIF/PNG appropriately (ie. generally don't use PNG for photographic images)
    • Use sprites for small images since you can pack a bunch of small images into one file giving you only a single HTTP request instead of dozens or more. You might consider font icons as well.
    • Save images at the lowest possible quality while remaining acceptably viewable. I find the sweet spot to often be around 50-60 quality for JPEG. Sometimes a quality of 20 is perfectly acceptable, and you might reduce an image from 300Kb to 30Kb. That's big savings.
    • Consider lazy loading on image heavy pages.
  2. HTTP Requests - Another big offender. Sometimes there's just not a lot you can do to reduce requests, but you should always try to get this as low as possible. Magento provides some features to help with this out of the box (merging CSS/JS).

  3. Additional DNS lookups - I'd say this is most important for the cart/checkout process. Many stores will have various API integrations that call services. While you can't do much to make an API response from a shipping provider much faster, you can at least identify slow services that aren't going to be readily apparent otherwise. Think about the additional time a checkout might take if you are making calls to UPS, FedEx, USPS, Tax rate providers, Payment providers, affiliate sites, etc.

  4. Other factors - Some of the other factors mentioned in your report are probably not going to have as big an impact as Images and HTTP requests. It can certainly be worth it to minimize CSS and Javascript, but the real-world gains are only really noticeable in the long-term aggregate. Also, a CDN can really help, especially if you are offering downloadable products.


I think there is often too much importance placed on hosting alone. In the past, I have been tasked with performing certain server tweaks for sites to improve speed, only to find out the home page is loading 20Mb of assets.

Likewise, the Magento white paper on server performance isn't going to be of any use if your site is built sloppy with too much bloat. If your goal is to improve your site's speed, step one should be looking at the pages themselves to find inefficiencies. Only after you've determined your site to be as lean and mean as you want it should you start considering upgrading your hosting.

For the record, a site I manage has been using a SIP-200 on Nexcess for about five years or so and receives an average of 5000 visits a day (it's seasonal, so it peaks over 10k in the late Spring/early Fall). I have absolutely no complaints about this grade of server for this site, and we are running a fairly stock version of Magento CE with thousands of products across dozens of categories.

| improve this answer | |
2

Images are a huge problem on the internet, almost as big of a problem as javascript. The first thing that you need to do is optimize your images.

  • Setup a Content Delivery Network
  • Optimize your images
  • Use an Image LazyLoader

Now onto your Javascript files:

  • Compress and combine them
  • Eliminate additional page reloads by using more ajax
  • Drop your JS files into the footer
  • Load your JS files from a different domain

Cache like crazy

  • Enable MySql caching and increase the size of the memory pool
  • Enable APC caching so that PHP doesn't have to relearn itself each time
  • Enable Magento Full Page Caching and utilize Apache Caching
  • Enable GZIP to deliver your files to the user faster.
  • Enable the proper Expires Headers so that your users are caching too

Magento also has a number of internal caching mechanisms:

  • Enable the obvious Magento Caching
  • Enable CSS and JS Compression and Compiling from the admin
  • Enable the Flat catalog and products to speed up mysql calls
  • Enable the Magento Compiler to speed up the PHP autoloader

If you want more details I've pulled the information from this knowledge base.

| improve this answer | |
0

Here is what I would suggest to speed up Magento site:

  1. Perform 3rd-party extensions audit and TTFB audit. Some custom plugins slow Magento down. Get a list of all 3rd-party modules and disable them one by one. Benchmark speed with www.webpagetest.org. When you identify an abuser contact its vendor to let them know. To run TTFB audit install a free program xhprof or use NewRelic.

  2. Find out if your hosting resources are enough to run Magento. Install a fresh copy of Magento the same version on your hosting. Compare its speed to the live site. If it is significantly faster than your site then your hosting is OK. If it is as slow as your live site then your hosting is not good.

  3. Perform various frontend optimizations. These include: image optimization, gzip compression, CSS/JS minification. You can get a report of what you need to do by running your site against Google PageSpeed Insights.

Taken from my article.

| improve this answer | |
  • What is the best way to do 3rd-party extensions audit? Thanks. @Konstantin Gerasimov – Gem Nov 2 '18 at 13:21
0
  • You need to focus both on optimizing your website (structure, CSS, images, etc.) and on finding a really fast host.

  • I would suggest you look for a host that gives SSD storage and Cloudflare CDN and which hosting services are specially optimized for a Magento-based website.

  • I'm currently using the so-called ''Popular'' plan for my website and for it's doing a great job.

  • Here are its full specifications: https://www.bgocloud.com/hosting/websites-cpanel/popular-plan .

If you think these features are not suitable for you, you can take a look at the other plans or at the dedicated servers page.

| improve this answer | |
-1

I've found the #1 most important thing in regards to site speed and magento is your server. Are you on a dedicated host? You have to be. Especially one with SSD drives. The slowest part of Magento is how it actually processes PHP and renders the page, and the only way to combat that is a better server. Also a full page cache, try Lesti FPC.

| improve this answer | |
  • Hi thanks for your response. I had a feeling our server configuration might not be what we need, but I am new here and just learning their system and never had to delve too far into the systems admin side of the job before. I dug up our latest invoice (assuming this is the server we are running Magento): 18636 Dual Xeon E5-2609 (E52609) RAM: 16GB Hard Drive 1: 500GB SATA Hard Drive 2: 500 GB SATA Hard Drive 3: 64GB Samsung 830 SSD Hard Drive 4: None Hard Drive Controller: On-board Controller – Brandon Jun 25 '14 at 18:15
  • I can't agree with this answer. If your site is bogged down by large images, tons of HTTP requests, and requests to 3rd party services (UPS, tax lookups, etc), the best dedicated host in the world isn't going to do anything for you. Get the site running properly to begin with and then consider upgrading hosting if applicable. – pspahn Sep 15 '14 at 21:02
  • FYI Brandon. The Samsung 830 is a disk drive designed for home computers, not servers. Doesn't sound like your server is a server at all. – choco-loo Oct 11 '14 at 7:23
-1

There is the long answer and the short answer, as Guido already pointed out these are the steps you need to follow for your setup. You'll need to find some competent resource to run through all the combinations to find the best fit, it's pretty time consuming but the standard process Magento sites need to run through. There is also a short answer but we work with an incubator and they use enterprise techniques primarily for higher end platforms, however ported it to Magento but it won't be relevant here. You'll need to find the exact balance between hardware, fpc, caching, business requirements, the only problem being once you've been through the exercise if you materially change anything you will need to rerun it.

| improve this answer | |
-1

Or you skip all that, use the same technology stack as Etsy, the same hosting as Very with multi-nodes, skip the fpc, near fpc ttfb, 1-2s dynamic loads, and use Pagespeed all added together giving you As across the board. Now, if you have over zealous coders and extensions added there are limits. It depends if you want to take the technology route and have to go through it all to the nth degree where programmers will disagree with the business, or you take the business view and find the best solution regardless of the technology protests often resulting in less technical work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.