Slow TTFB - is this something I'm doing?

Hi Folks,

I’m seeing quite a slow TTFB with our site hosted on Render (using the Docker runtime):

› curl -I -o /dev/null -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://whatsfinished.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
Establish Connection: 0.283034s
TTFB: 1.701468s
Total: 1.701554s

Compare that with say, Google:

› curl -I -o /dev/null -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://google.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   220    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Establish Connection: 0.088311s
TTFB: 0.397731s
Total: 0.397840s

The processing in the Rails app is taking ~4-5ms consistently (just rendering a very simple static template). I know it’s not a massive deal, but you never know how many impatient internet people you’ll lose in those ~2seconds :upside_down_face:

Is there anything I can do to speed this up? I’m guessing this represents time in the Render router? Or maybe it’s a geographical difference (I’m in New Zealand) - although wouldn’t Cloudflare alleviate that somewhat?

Thanks in advance!

Nik

1 Like

Hi @nikz ,

I do suspect this has to do with geography and general Internet topology. I just ran your example (thank you so much for that!) and got 0.24s TTFB:

❯ curl -I -o /dev/null -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://whatsfinished.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Establish Connection: 0.056814s
TTFB: 0.243791s
Total: 0.243965s

I’m located on the same coast as our Oregon region, where your service is hosted, this fairly fast TTFB is what I would expect. We only provide a CDN for our static sites, and not for dynamic sites like yours, so using something like Cloudflare may make sense. I know other users are successfully using Cloudflare in front of their Render services, so it’s certainly a valid route to explore.

We don’t have any docs on setting up a custom proxy like Cloudflare in front of Render, but I’m happy to answer any specific questions you’ve got if you decide to go that route.

Hi @dan - thanks for the reply.

I think I just assumed Cloudflare was automatic for the dynamic sites too - so that’s my bad. I can set it up myself easily enough I think!

Cheers,

Nik

Sounds good! Good luck :slight_smile:

Just to clarify, Render doesn’t use Cloudflare at all. Static sites are served through a CDN, but it is not Cloudflare.

1 Like