Magento 2 and Adobe Commerce performance issue: response time degradation
Slow Magento site TFB response performance.
Long response time caused by the cache being invalidated (flushed).
The cache is used to generate fast responses to the site visitors’ requests. If there is no appropriate cache data available, the Magento application fetches the data from the database, runs millions of line inefficient Magento PHP code, calculates and aggregates the data, and stores it in the cache storage. The cache generation process requires additional enormous system resources, causing total response-time degradation.
But what’shapanning if you are having active e-commerce websites with tons of product orders and constant inventory synchronization? Magento will erase the cache all the time.
You can find information regarding the invalidated cache types in the <install_directory>/var/log/debug.log file.
To do this:
Open <install_directory>/var/log/debug.log
Search for “ cache_invalidate “ message.
Then, check the tag specified. It indicates what cache was flushed. You might have issues because of the invalidated cache if you see a tag with no particular entity ID specified, for example:
cat_p – stands for catalog product cache.
cat_c – catalog category cache.
FPC – full page cache.
CONFIG – configuration cache.
Having even one of them flushed would slow down the website’s response. If the tag contains an entity id, for example, category_product_1258, this would indicate the cache for a particular product or category, and so on. Flushing cache for a particular product or category would not cause response time to drop significantly.
Following is a sample of a debug.log containing records about the cat_p and category_product_15044 cache having been flushed:
sample of the debug.log content
Usually, the cache becomes invalidated because of the following:
- Add/edit product
- Place order
- Update inventory
- Add/change category
- Price changes
Recommendation:
Don’t really on FPC and improve unmatched page performance. All Magento developers are thinking about why to write good code and if any way it will be cached. So you need to improve the performance of the uncached page generation and not be fulled by unreliable cache performance.
If your TTFB response time is more than 800 ms, it is a bad sign. However, I’m recommending TTFB under 400ms. Google recommended TTFB up to 800mm because most of the web is sucks.