Reading list Switch to dark mode

    Blackfire Load Testing with Magento and Magento2

    Updated 4 March 2024

    Blackfire Load Testing with Magento and Magento2 – As we all know that if a webpage takes too much time in loading then no one will visit that website, so it is very important for a website a take a less load time. We all know that magento is a complex framework and many blocks and files are called in a single page, so it’s very hard to recognise a method which is taking too much time in loading a page, so using blackfire we can find which method is taking too much time in loading a page.

    We know that there are many caching tools which is used to speedup the performance of a website but if there is something wrong with code then nothing will help you out, you will need to optimise the code. So that’s why I am explaining here about blackfire load testing with magento.

    For more information about blackfire please check following link –  https://blackfire.io/docs/introduction

    Blackfire Installation – For this we will need to follow few simple steps-

    Step 1 – If want to profile your page via browser then you will need to install a blackfire extension for chrome and for this please follow the link – https://blackfire.io/docs/integrations/chrome .

    Searching for an experienced
    Magento Company ?
    Find out More

    Step 2 – Now follow the simple instructions given in link https://blackfire.io/docs/up-and-running/installation#installation-instructions to install the blackfire on your magento server.

    Step 3 –  Now blackfire is successfully installed in your magento.

    Blackfire Load Testing with Magento – Here I am profiling the magento home page with backfire.

    0086ddb96fd241df8848398cff5c844e

    Now click on the “Profile!” button to test load time of home page.

    e6a46589fc4b445694d34a12089beffa

    In the above screenshot we can see that home page is taking 520ms time and now I am calling new product block in home page to display 5 recently added products. Please check the screenshot after adding new product block to home page.

    dc53056850294c60bc04447ba2bb4632

    Now home page is taking 802ms in loading page, and when I checked it’s profile graph then we can see the new_grid.phtml is taking 254ms.

    fd858ee6010d403185d2fdf60c6e70a1

    I checked the productCollection() method and optimised that method as much as possible, now this we can see that the home page is taking 760ms instead of 802ms, so in this way we can optimise the webpage using blackfire.

    Code Before Optimisation –

    $collection = Mage::getResourceModel('catalog/product_collection');
            $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
    
            $collection = $this->_addProductAttributesAndPrices($collection)
                ->addStoreFilter()
                ->addAttributeToSort('created_at', 'desc');
            return $collection;

    Code After Optimisation –

    $collection = Mage::getResourceModel('catalog/product_collection');
            $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
    
            $collection = $this->_addProductAttributesAndPrices($collection)
                ->addStoreFilter()
                ->addAttributeToSort('created_at', 'desc')
                ->setPageSize(5)
                ->setCurPage(1);
            return $collection;
    56ab7c96c65b494fa6163e9f5f4fb53c
    screenshot_3

    Also blackfires offers some built-in metrics for magento https://blackfire.io/docs/reference-guide/metrics#magento-built-in-metrics and some recommendations https://blackfire.io/docs/reference-guide/recommendations which will be helpful to improve the performance of your website.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home