Performance Tuning Methods

There are several methods and system configurations available to analyze and increase a store's page performance.

  • Enable Flat Categories and Products:
    1. Navigate Stores - Configuration - Catalog - Catalog - Storefront.
    2. Select Yes in the Use Flat Catalog Category field:

  • Merge CSS and JS files:
      • Navigate Stores - Configuration - Advanced - Developer - JavaScript Settings.
        1. Set Merge JavaScript Files to Yes.
        2. Set Minify JavaScript Files to Yes.
      • Navigate Stores - Configuration - Advanced - Developer - CSS Settings.
        1. Set Merge CSS Files to Yes.
        2. Set Minify CSS Files to Yes.

  • Full-page Caching(FPC):

    By default, Magento provides a full-page cache on the server to optimize the display of various pages, such as category pages, product pages, and CMS pages. If full-page cache is enabled, you can reduce the response time of your store since in that case a fully generated page can be read directly from the cache. The customer experience will be improved, and you can increase conversion rates at once.

    • To enable Full-page caching:
      1. Navigate Admin - Stores - Configuration - System - Advanced - Full Page Cache.
      2. In the Caching Application field, select Built-in Cache, and set a sufficient time-out in the TTL for Ppublic content field. The default value is 86400.

      Magento, however, recommends this mode of caching only in the developer mode or in a low-traffic production website. The reason it will not be able to deliver the performance levels of the next option, Varnish Cache, is because all traffic is still routed through the web server, and so Magento must still handle all requests, even for a fully cached page. This might cause a performance bottleneck for high-traffic production websites.

    • Varnish Cache:

      Magento 2’s built-in Full-page Caching (FPC) feature is not considered an optimal solution to get sufficient performance. In production mode, it is highly recommended to use Varnish Cache for optimal performance.

      For more information on Varnish installation and configuration see:

  • Magento search optimization:

    Starting in version 2.4, Elasticsearch replaced MySQL and became a default search option for Magento. Elasticsearch is geared for search: it is faster than MySQL and more flexible in tweaking terms. Search queries are considered heavy due to the numerous criteria they must meet. So, the search logic has been detached to offload MySQL and optimize the overall speed of the Magento search result page. Usually, Elasticsearch is configured on a different server so that search queries do not impact the main server performance.

    For more information on installation and configuration details of Elasticsearch see:

    https://devdocs.magento.com/guides/v2.3/config-guide/elasticsearch/es-overview.html

  • Image optimization:

    Since merchants need to show a lot of different types of images in their stores, it is important to optimize those images to reduce the overall size of the page. Even though other performance-related optimizations are needed, if the images are not optimized properly, there will still be hiccups in getting the best performance results. Therefore, always try to use compressed images for banners, icons, product catalogs and categories, and so on.

    There are several techniques available to optimize the image load:

    • Compress images:

      There are many image compression techniques which can be used within the store using libraries or using tools like TinyPNG and ImageOptim to compress images before uploading to the store.

    • Use Content Delivery Network (CDN):

      The best CDNs offer smart image compression as an additional benefit to users' subscription. Cloudflare’s Polish feature is a good example which can provide countless built-in image optimization techniques. Some CDNs even go as far as offering conversion to modern image formats (WebP, JPEG XR, JPEG 2000), latency reduction, on-the-fly compression, and so on.

      Any user who comes to the store will be served a cached version ofan optimized image, which reduces bandwidth and improves browsing performance. CDNs can serve images in WebP format to suitable web browsers.

    • Use multiversion images for screen resolution:

      Responsive design offers new challenges and opportunities to Magento developers. One such opportunity is the use of various image versions for different screen resolutions. Depending on the viewpoint, Magento can show users the version of the image that best suits the display.

  • Upgrades:

    Make sure the hosting servers are updated with the latest version of Magento 2 as soon as the stable version is officially released. Magento releases new versions of the CMS every 3-4 months and each release has performance upgrades or security fixes.

    Apart from Magento 2 upgrades, make sure to update any third-party modules used in the store (including LS Retail modules) as soon as an update is released.

  • Review third-party extensions:

    Magento with core modules usually performs well. Problem can arise when third-party extensions and custom modules are used to enhance features. Each module works separately and hence requests dependent objects and classes as required which could build up over time. So, in order to further improve performance, it is necessary to review from time to time all third-party modules that are installed and uninstall those which are not required anymore.

  • Review page performance using Magento Profiler:

    Magento Profiler is a simple profiling tool that you can use to inspect database queries and the different calls of various methods. Magento Profiler is great at finding bottlenecks, slow-downs, and other hidden Magento performance issues.

    See https://devdocs.magento.com/guides/v2.4/config-guide/bootstrap/mage-profiler.html

    There are also some specialized extensions which work on top of the Magento Profiler which you could also use, for example Mirasvit Module Profiler, MGT Developer Toolbar, and more.

  • Magento DB Profiler:

    This DB profiler tool displays all queries executed on a particular page load, the time taken for each query, and what parameters are executed.

    See https://r-martins.github.io/m1docs/guides/v2.4/config-guide/db-profiler/db-profiler.html

  • Developer for Toolbar for Magento 2:

    This debug tool helps speed up the Magento 2 development process. The tool displays the information related to each section listed below

    • General Info: Details about controller, route, action, and store. Dedicated tab output for local and global phpinfo.
    • Design: List of layout handles called and layout structure of nested blocks and containers.
    • Profile: Observers, events, collections, models, and plugins instantiated in current page.
    • Queries: Listing of executed queries and load time with syntax highlighting of main SQL keywords.
    • Logs: Display log files with the ability to reset these files.
    • Translation: Details on module, pack, theme, and DB translations.
    • Actions: Easily toggle template hints and inline translation and flush cache.
    • Help: Show module version and link to GitHub.

    See https://github.com/vpietri/magento2-developer-quickdevbar

  • Page performance analysis using New Relic:

    New Relic is an application performance management software which monitors your application in real-time and alerts you if there are any glitches. It helps you identify the details like function or logic in your code that is causing performance issues, the SQL query, which is taking more execution time, and so on. For more details on New Relic configuration and its features see: