-
Notifications
You must be signed in to change notification settings - Fork 156
High TTFB with PageSpeed #2089
Comments
Thanks for the data including the config; it's very helpful. It does look like the performance is pretty good even from the US, despite the TTFB. I assume the server is in Germany with no US CDN. Of course TTFB will never get faster with PageSpeed, only slower. The question is whether the optimizations it makes during that time provide a better user experience. I visited view-source:https://www.keinegotterkeinemeister.de/tshirt-sabotage-black-cat-D01004174288P0210/?PageSpeedFilters=+debug to see what timing info PageSpeed injected at the end, and found this:
So it looks like your server spent 5.7 seconds in PageSpeed parsing your HTML -- that's mostly CPU bound. Then it spent 452ms rendering it -- that may be a combination of image optimization, network operations, waiting for asynchronous optimizations and URL fetches (depending on the cache setup) That leaves 1100-270= 378ms unaccounted for. I'm guessing that most of this comes from the file cache. It's possible your disk is I/O bound. My main suggestion is to try deploying memcached or redis as an asynchronous cache. That should be faster than the file-cache. |
Hi, thanks for the reply The server is a dedicated server in OVH Datacenter in Beauharnois, Quebec, Canada CPU load is always under 25% https://prnt.sc/Xte_RHbEGSgR We also integrated a benchmark into the website to calculate the page load speed of the different PHP modules and calculate SQL queries execution time. You can see it on the bottom of the page when adding ?benchmark=1 to the URL Currently, it takes 0.2110 seconds to generate the page with PHP on the first page load. But out of this 0.21 seconds, 0.1865 is due to calling an external geolocation API. This is just because Cloudflare is currently disabled for our testing phase. When Cloudflare is enabled, we get the geolocation from $_SERVER["HTTP_CF_IPCOUNTRY"] so we avoid calling the external API and page load time goes down to around 0.01s TTFB is not the only problem, we also have high LCP and it throws warnings in Google Search Console: https://prnt.sc/2PjB74ekUgdR How can I confirm whether the disk is I/O bound or not? I followed Plesk guide and here are the results:
This seems pretty slow. Could it be because we run pagespeed from too many domains? Latency seems fine:
however iotop looks perfectly fine. Monitored it for around 10 minutes and IO never went above 1% also no high %WA with top: |
I was suspicious there may be spinning-disk latency but as you have an SSD I'm not sure. Nevertheless it might be worth trying redis/memcached, as we never really tuned the file-cache for SSD. |
There could be an IO issue because according to the Plesk guide, the first test I ran should get a speed of 142 MB/s but I got only 183 kB/s Memcached is now installed but I'm not sure how to check if it's correctly configured
Is 51200 enough? We have plenty of memory on the server and the websites are big with thousands of images It seems to have lowered TTFB, great! Now it is almost the same as with Pagespeed disabled. Thanks! Anything suggestions to improve LCP? |
The shared-memory metadata cache does not get populated with images. It
just gets populated with metadata mapping the original image name and
context into which it is to be rendered into an optimized resource name.
The images are stored in memcached in your configuration. You can see the
hierarchy pictured here:
https://www.keinegotterkeinemeister.de/pagespeed_admin/cache#cache_struct
It look like you've got Prioritize Critical CSS enabled. I haven't
thought about this space for quite some time but I don't think we have much
else in PageSpeed I'd recommend. I"d try disabling defer_javascript -- it's
possible it's doing more harm than good to that metric.
Good luck!
…On Mon, Apr 11, 2022 at 11:52 PM Ungov77 ***@***.***> wrote:
There could be an IO issue because according to the Plesk guide, the first
test I ran should get a speed of 142 MB/s but I got only 183 *kB*/s
Memcached is now installed but I'm not sure how to check if it's correctly
configured
https://www.keinegotterkeinemeister.de/phpinfo.php
I enabled statistics and I can see some data related to Memcached so it
seems to be working:
https://www.keinegotterkeinemeister.de/mod_pagespeed_statistics?memcached
ModPagespeedMemcachedServers localhost:11211
ModPagespeedCreateSharedMemoryMetadataCache "/var/cache/mod_pagespeed/" 51200
Is 51200 enough? We have plenty of memory on the server and the websites
are big with thousands of images
It seems to have lowered TTFB, great! Now it is almost the same as with
Pagespeed disabled. Thanks!
Anything suggestions to improve LCP?
—
Reply to this email directly, view it on GitHub
<#2089 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAO2IPIHW2BALPOWN7TII53VETXQJANCNFSM5TEGVEXQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
One more thing -- you probably should control access to /pagespeed_admin and /mod_pagespeed_statistics with allow/deny directives per https://www.modpagespeed.com/doc/admin#handlers |
Thanks, we disabled defer_javascript and some other filters However today we noticed that images are not getting converted to webp anymore after switching to Memcached |
My first suspicion is that they just haven't been (re)converted into webp yet. By switching to memcached you effectively are flushing your cache. As you may have noticed, PageSpeed optimizes resources in the background when it learns they need to be optimized, but may serve the first few requests unoptimized. Is it possible that if you refresh your page a few times the images will start coming in as webp? |
I tried CTRL+F5 many many times but I didn't see any webp images in the code. As soon as I turn off Memcached, I see webp images after 2 refreshes. We let Memcached be enabled for 18 hours and didn't see any webp images on the homepage. Memcached disabled, many webp images in the code: Memcached enabled for 18 hours with zero webp in the code: |
I see this error in /mod_pagespeed_statistics?cache#physical_cache I temporarily re-enabled public statistics on both domains if you want to check
edit: got it enabled now, but still confused about the last line, inactive/dead
Now the error is gone in /mod_pagespeed_statistics?cache#physical_cache edit: it's fixed, webp images are working now edit2: TTFB is now back above 1200ms 😭😭😭 |
It's possible the reason that TTFB was good for a while is that the memcached code is good at failing-fast if it looks like memcached is not working. I can think of three reasons generally that PageSpeed would make TTFB noticeably worse:
|
Hi, Makes sense. I didn't understand how it was faster with Memcached failing lol I don't think the rewrite deadline is being overwritten. I have not modified any conf file, the entire config is in Plesk GUI except for ModPagespeedCreateSharedMemoryMetadataCache I have looked at the histograms but I'm not sure how to interpret the data You can check the admin section, I put it public temporarily again |
Hi @Ungov77 @jmarantz Take a look on this: https://www.keinegotterkeinemeister.de/pagespeed_admin/cache#physical_cache See evictions and current objects stored: curr_items: 53457 I think is a big amount of evictions. You are using only a 64Mb memcache database bytes: 63936177 In the config file for memcached (normaly /etc7memcached.conf or /etc/system/memcached.conf) you can increase the size of RAM memcached uses: change Think you are using memcached to store those object stored in disk before. |
Hi, The config file aas in /etc/sysconfig/memcached What size should we increase it to? We have 64gb of ram on this server edit: 1 hour later, Evictions are still at zero. Seems to be fixed now. |
hi @Ungov77 |
Hi,
TTFB is much higher when PageSpeed is enabled and I don't understand why
264ms TTFB with PageSpeed=off
https://speedvitals.com/report/www.keinegotterkeinemeister.de/eEuqEG/
1100ms TTFB with PageSpeed ON
https://speedvitals.com/report/www.keinegotterkeinemeister.de/tg1zwa/
Pagespeed config:
https://pastebin.com/fLqVcP1M
The text was updated successfully, but these errors were encountered: