TTFB too high, 1 sec load time for single file with phpinfo();

June 16, 2017 590 views
PHP Frameworks WordPress Server Optimization Ubuntu 16.04

Our wordpress site is showing Quite big TTFB , i created blank file with phpinfo() and loaded the website and it is the same TTFB of 1sec, so iguess wordpress is not slowing , something else on our server must be doing this

what part of server i should be optimizing?

i am running Ubuntu 64 bit with httpd , php-FPM and mysql.
[http://i.imgur.com/iW5NAAB.png](http://)

1 comment
  • ran another test

    1) wp loads with 1 sec of load time
    2) a file with phpinfo also loads with same wait time
    3) html file loads with 800ms of load time.

3 Answers

@lalitnagrath

TTFB can be affected by most areas of your stack, ranging from DNS to the Web Server, PHP to the database server, and everything the falls between.

Reducing TTFB can generally be achieved by implementing some form of caching and using a CDN. I would recommend either WP Super Cache or W3 Total Cache (the more complex of the two).

If you want super-simple, use WP Super Cache.

As far as a CDN, you have numerous options, though I'd start with CloudFlare as it's free and rather easy to setup.

https://wordpress.org/plugins/wp-super-cache/

https://wordpress.org/plugins/w3-total-cache/

https://www.cloudflare.com

...

The physical stack can also come in to play, so making such your web server, whether it's Apache or NGINX -- the database server, whether MySQL, MariaDB, or Percona -- and PHP (where possible) is optimized and tuned is definitely critical. WordPress relies on PHP and MySQL heavily, so beyond any sort of caching, making sure the database server is tuned for the best possible performance is going to be an absolute must.

...

I would start by setting up CloudFlare and getting one (and only one) of those caching plugins setup. Once you have, re-test and see where you're at and we can troubleshoot from there.

Feel free to tag me in your reply by using @jtittle.

thanks for the reply @jittle but now my concern is TTFB for a plain html file. once slow TTFB request goes through, everything loads quite fast and whole website loads in under 5 secs as i have Cloudflare and Caching on.

just ran a TTFB test on my other client hosted on godaddy's readme.html file , it loaded in under 200ms.

so i guess something is wrong with my server config and i need assistance finding out how to find it out. been going over many articles over web from morning, most of apache's recommendation seem to be of old version . nothing seem to help.

  • Hi @lalitnagrath

    You should only use the CloudFlare DNS - otherwise every request to your site will go through CloudFlare. So if you use the cache on CloudFlare, then your TTFB will be longer than if you connected directly.
    CloudFlare even wrote a blog post about this:
    https://blog.cloudflare.com/ttfb-time-to-first-byte-considered-meaningles/

    To do a real test, use your droplets IP to view a file - that way you'll skip any DNS, CloudFlare caching, etc. from external sources and only focus on your droplets configuration. Example: http://your-droplet-ip/phpinfo.php

Have another answer? Share your knowledge.