Slow TTFB, how to debug?

You are here:
Estimated reading time: 2 min

This usually happens when there’s a lot of processing in the background.

It’s uncertain what causes this, but it depends entirely on the context of the website, where it’s hosted and what’s loaded inside. It could be a faulty plugin, or a slow query (or multiple queries) and so on.

Here’s a couple of things you can try to debug this:

LinkEnable debugging to see if there are PHP errors in the background

Follow this article to enable WP_DEBUG constant, and make sure to check if there are php errors generated.

LinkInstall Query Monitor plugin

Install the Query Monitor plugin to get reports of the number of queries, duration and overall DB performance, as well as memory consumtion.

After installing you should see the reports in the top Admin bar ex: .

For a quick comparison, here’s a screenshot of London’s demo Query Monitor overview .

The basic principle is avoiding a large number of queries. In that screenshot, there’s around 480 queries given that this page loads a large header with a lot of features, WooCommerce product grids, and other various elements that may need to query the DB.

LinkMonitor HTTP API requests in Query Monitor

Most plugins have some form of sending information to their respective API server to get the latest version information, in some cases telemetry data, and so on.

When you see a slow load, make sure to check the HTTP API tab in Query Monitor eg: . There might be a slow request, a bad request etc.

There were many cases in various sites where these types of request could take tens of seconds even minutes (depending on server timeout configuration). So make sure to verify it.

LinkDisable plugins, one by one

Given that the issue may come from a specific or multiple plugins, try disabling plugins one by one (and refresh in the meantime) to see if there are improvements.

I recommend keeping active only Query Monitor, WooCommerce, Elementor and Rey Core, and gradually activate the other plugins one by one until you can spot the one(s) that could add a bigger payload.

You can try disabling Rey Core plugin too, but please know that this plugin acts as a pipeline in many situations and a lot of content passes through it (eg: main content, product grids elements, Global sections – Header, Footer, etc.) and while disabling it will obviously show a decrease in consumptions and queries, but only because this content is not rendered anymore.

LinkUse Redis or Memcached

By definition, Redis and Memcached are both in-memory data storage systems. Memcached is a high-performance distributed memory cache service, and Redis is an open-source key-value store.

It’s probably best to ask your hosting support team if any of them is supported on your server.

LinkSlowdown when uploading content (images)

On each image upload, WordPress is generating resized variants of that image, based on preset sizes which are registered by WordPress itself (thumbnail, medium, large), WooCommerce (thumbnail, main gallery, gallery thumbs etc.) and even Rey (blog image, 16/9 sized image).

This process can be very expensive, especially on shared servers and especially if the images are very large and there are many pre-set sizes.

That’s why i recommend disabling some of these sizes with this plugin In fact, at least for the moment, i only recommend having the Large, Medium and Thumbnail enabled. If it affects the frontend in some way, you can enable other sizes later on and use this plugin to regenerate the images on those missing sizes.

To learn more about this please visit this article How to Prevent WordPress from Generating Image Sizes .

Was this article helpful?
Dislike 0
Views: 949

Suggest article improvements

Please use this form to suggest improvements and report missing or outdated content. Support requests will most likely not be answered and it's best to use the Support Request Form instead. Thanks!