Optimization for a Magento 2 site is critical for improving sales or conversions. Any area of a Magento site that loads slowly will correlate to a drop-off in visitors, and ultimately a drop in revenue. Magento 2 is a complex eCommerce engine, so sometimes it can be difficult to pin down where problem areas are. Is a single page loading too many blocks? Is a template file loading too much data for a single product page view? Knowing exactly where a bottleneck is makes it that much easier for your web developer to deploy improvements.
There are server configurations that can help, usually these are in the form of cache (a storage location with very short access time used for frequently / recently used instructions & data). Cache tools like Redis, Varnish, etc. will be able to speed up your site, but they can only do so much. If there are problem functions in custom code or 3rd party extensions, these can still cause loads to be much slower than desired.
Magento & BlackFire
BlackFire is a powerful performance / profiling tool that we use in our client’s Magento environments to find performance bottlenecks and to facilitate testing and continuous code improvement. BlackFire provides a variety of metrics that can help your developers speed up and identify problem areas in your Magento installation. These metrics include wall time (i.e., the speed in which a function runs), I/O time, CPU time, memory consumption, query speed, and others. Basically, these metrics are extremely granular, and wouldn’t be possible to measure without a tool like BlackFire.
The granularity extends to a function by function basis, so you can determine the exact function in an extension or template that is taking too long to process. This makes it easy to diagnose the site page by page, removing the need for ‘educated guessing’. This helps diagnosing a site as large and complex as a Magento 2 installation much, much faster.
BlackFire runs automated tests that you schedule how and when they are run. For example, on Magento Cloud, when you push code to the cloud environment, BlackFire automatically runs the scenario tests that you define and include in your file-system.
BlackFire scenarios and tests are setup in a yml file. It looks a little something like:
tests: Pages should be fast enough: path: /.* assertions: - main.wall_time < 850ms - main.io < 500ms - main.cpu_time < 500ms scenarios: Home: - / Cart: - /checkout/cart/
The structure of the yml file is pretty simple. First, define your tests. There is a lot of documentation here, but your developers will be able to define the tests that should be run. The default tests that come with Magento Cloud BlackFire setup that are a good starting point.
The second set of configurations are the scenarios (or URLs, basically) that you want to automate all the tests for. BlackFire will run all tests at every scenario you list. This can let you get tons and tons of data from a huge variety of URLs.
BlackFire for Chrome
Another cool feature of BlackFire is it’s Chrome extension. It can let you ‘at a glance’ get performance data while you browse around your Magento site. Visit the Chrome extension store and install BlackFire for Chrome. Once enabled you can browse to any URL on your site you would like to profile. Create a reference profile, then click the ‘Profile’ button. Within a few seconds you will have a Call Graph or Comparison Graph to view and see the results.
Take Control of your Magento Performance
BlackFire can help demystify your Magento 2 installation and provide real data for you and your developers to improve performance. Your reward will ultimately be a better shopping experience for your customers, and real improvements for your bottom line.