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

Cherian
  • 789

2 Answers2

5

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.

Tim
  • 33,870
  • 7
  • 56
  • 84
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.

Gothrek
  • 551