1

I serve a wordpress blog with nginx http cached to over 99% of the requests with a cache lifetime of 2 days. Here’s a webpage from the site. The webpages have quite a few images and therefore lazy loaded. The average size of the page is just one 1 mb.

The median response size is 10 KB

enter image description here

With speedcurve my TTFB is at a median of 0.6 seconds

enter image description here

Why is it this high?

I am behind cloudflare and all static assets like JS, CSS and images are versioned and cached from cloudflare.

My nginx config has

    sendfile        on;
    # https://forum.nginx.org/read.php?2,280434,280434#msg-280434
    tcp_nopush on;
    tcp_nodelay on;

    #https://support.cloudflare.com/hc/en-us/articles/212794707-General-Best-Practices-for-Load-Balancing-at-your-origin-with-Cloudflare
    #https://www.nginx.com/blog/tuning-nginx/
    keepalive_timeout  300s;
    keepalive_requests 10000;

I also have

initcwnd set to 10, initrwnd 10 and ipv4.tcp_slow_start_after_idle=0

Here’s cloudflare’s reporting of the response time from CF to origin enter image description here

Here’s my webpagetest.org results for a 2G connection

enter image description here

The static website is also load balanced across two machines. One in Fremont and one in Mumbai with Cloudflare doing geographic routing.

Why is it that my TTFB this long and what can I do to reduce it?

enter image description here

4

I re-ran the test from Mumbai with no bandwidth restriction and got a TTFB of 237ms for the page and 7ms for a static resource.

You restricted the test to 2G, which is very low bandwidth.

So the problem isn't the website, it's the restrictions you placed on your test.

  • I agree and intent there is to blow up each request to test and understand. But if you look at the speedcurve TTFB results, they are based on RUM and at 0.6 seconds. It shouldn’t take that long in the real world IMHO. – Cherian May 12 at 9:01
  • 1
    @Cherian On a real 2G connection it would probably take even longer. The user's lack of bandwidth is not something your web site can fix. The web is just not usable on 2G any more. It's barely tolerable for email and chat. – Michael Hampton May 12 at 18:06
  • I wasn’t trying to contradict Tim. If you choose to ignore the webpagetest results, the real world test results for TTFB is still 0.6 seconds, which IMHO is still high for a static website serving content at low latency (load balanced) to end users. – Cherian May 13 at 11:28
  • @Cherian I get your sample page in 139ms-144ms TTFB. Are you still having a problem? – Michael Hampton May 15 at 3:44
  • @MichaelHampton personally no, but Speedcurve is reporting over 950 ms in response time. I am going to try see if moving the page cache to Cloudflare (set expires to 2 hrs) will give some improvement – Cherian May 16 at 5:06
0

Are you getting the same results when skipping Cloudflare? What about doing ab locally? Even with a beefy connection I'm getting ~200ms TTFB. It might be that simply connecting between Cloudflare edge and your origin is taking that much time due to distance.

You could turn on full page cache and that would improve your TTFB immediately.

  • A full page cache with cookie invalidation (Which is the only way to do this correctly using wordpress) requires a $200/month business plan. – Cherian May 20 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.