TTFB (Time to first byte)

Posted April 4, 2015 9.6k views
NginxCentOSMySQLPHPServer OptimizationNetworkingCachingMariaDBLEMP

I wonder if someone could answer my questions about TTFB:

What can be done on the server to speed up TTFB for a first time visitor? The main issue is TTFB for the very first visitor. (I don’t use CDN but I tested locally)

when I PING I get in average 0.045ms for the IP, so that is awesome! There is no domain connected to the IP.
But when I go to the IP address with Chrome TTFB is going up and down from 1.5s to 3.5s from time to time.

The file is 123kb and content download is around 0,5-1ms. Initial connection is 1,7ms and stalled is 1,6ms

When I turn on simple gzip cache in nginx.conf the file that was 123kb is now only 18kb. DNS lookup, connecting and sending are 0ms. TTFB is between 1.1 to 1,6s and content download is 0-1ms.

I’m not sure where to start searching for the issue?
Redis frontend cache and session is installed and working, haven’t tried to see what happens with the TTFB if Redis is turned on yet because the main issue is not TTFB when the site is cached, the main issue is TTFB for the very first visitor.

Maybe not much I can do about it?

i run a droplet with 4gb ram, centos 7, nginx 1.6.2, php 5.6 with opcache and mariadb 10.
I run magento on the droplet.

Any suggestions for what and where I should look are grateful !!

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

I just switched a website over to Digital Ocean and the first comment from the website owner was regarding the TTFB. The site is in NY, the owner is browsing from Florida. I haven’t set up CDN yet as I have to ensure that the other caching mechanisms (memcached, WordPress Object Cache, PageSpeed and Varnish) are working well together first before adding yet another layer of caching so I would like to understand better why there is a longer TTFB that’s so noticeable compared to previous setups. It does appear to be the first visitor after a period of inactivity. Is my droplet going into some kind of low powered mode?

TTFB is somewhat a famous problem with DO.

To test whether it is due to DNS, PHP, Wordpress, hosting or some other issue, I copied my website to Google Cloud, and ran it with Google’s Compute Engine instance.

I got much faster server response times and passed the Pagespeed test with flying colors even with the smallest VPS config.

So it’s not due to PHP or Wordpress. Digitalocean server does have server response time issues. With Google I can get 100-300ms response time, whereas here it’s more like 1.0-1.2s.

But comparatively, DO is cheaper and has nicer UI :)

I have similar problems with ttfb. Even with cloudflare I am getting info message on pagespeed insights.

Tried also with varnhish caching to nginx pagespeed module, 2 droplets 4 GB and 3 GB.
Same thing.

Hi DO, any chance to fix this issues about TTFB?

We also have slow TTFB with our Digital Ocean server. The server spec is high (with little load) and we are running a CDN but a lot of our content is dynamic so needs to be pulled directly from the source.

Unfortunately we had to move from DO Spaces to S3 recently because of performance issues, it would be a real shame to have to do the same for our servers.

We really like DO but the issues we have faced have a direct impact on SEO and general visitor experience.

Have you guys this problem with another services, like postgre, ssh, ftp, etc? all services running here appear to be slow on the fist connection, and send files over ftp … sux