4

I have trouble reducing TTFB on PHP.

Even when file is empty it needs about 100ms. It doesn't matter .php or .html, both need the same time.

I have a decent server on HETZNER, server is not loaded and shoudn't have any problem.

Can it be problem with Cpanel?

Is it possible to have lower TTFB on php 7.0 (empty file)?

I managed to reduce connect time by changing DNS Server from hostgator (LaunchPad) to cloudflare (it was about 100ms and now it's ~1.5ms).

Any suggestions?

temo
  • 612
  • 1
  • 9
  • 25
  • Please, explain why you are downvoting so I can improve my question quality. Or don't downvote at all. Some users make hard not to speak about their mommas here, but I manage somehow. :) – temo Sep 24 '18 at 12:07
  • 1
    It's likely it is related to your webserver configuration, but we can not help any further without knowing how is your setup done. As a "general" advice, proxy/caches and the like might be what you are looking for but we can't help without any further info. Nevertheless below 100ms is usually ok for ttfb. – L. Amigo Sep 27 '18 at 08:42

1 Answers1

1

TTFB depend on network latency.

I've just performed a test on my web application I'm developing. The chrome TTFB analyze on my test server showed 225ms on my LTE connection, and the same application runs on my computer apache server has 14ms TTFB in chrome. The ping test to my local machine shown 0.015ms latency, and the server 64ms latency. This is probably why your TTFB cannot be reduced under 100ms. It's rather your network connection latency and not the application. Try to perform the test on very fast connection or use apache ab to test it on the server console.

  • Nice suggestions thx. I tried apache ab and one request needs _1.430 milliseconds_ on `http` and _9.505 milliseconds_ on `https`. When I test file on other platforms (i.e. _apiscience.com_) it says the same as my browser. So could it be problem with provider (Hetzner)? – temo Oct 04 '18 at 10:38
  • 1
    you were making ab tests from your server on other platforms and the request times were similar to Your home network browser tests? apiscience is in USA and Herzner in Europe. You should test it on platforms in your country. Ping from Europe to USA is at least 100ms long. – Krzysztof Czerwiński Oct 04 '18 at 14:07
  • I've set up same configuration apache server here in my country (Georgia) and it acts the same way from apiscience but from a browser, it is extremely fast. I think I have my answer and I need different servers in different locations to achieve my desired request speed. I'm glad you stumbled on this question cause nowhere else was pointed out that TTFB could raise due to network latency. If you have any workaround for me, in this case, I will appreciate it, else I will need more servers in different locations. thx :) – temo Oct 04 '18 at 19:47
  • Sry, I think bounty has expired and I can not give it to your answer. – temo Oct 04 '18 at 19:51
  • 1
    There is something called CDN hosting, your application can be spread in many different locations around the world. – Krzysztof Czerwiński Oct 04 '18 at 20:15