Current time: 12-12-2017, 12:56 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Sometimes Long Time to First Byte Time for the first request
10-20-2013, 04:24 PM (This post was last modified: 08-20-2014 08:05 AM by BITS.)
Post: #1
[Solved] Sometimes Long Time to First Byte Time for the first request
Hi,

in the last couple of weeks I am working on improving the performance of my website. After several hundred tests via webpagetest.org there is obviously one thing, I cannot understand yet.

If I test my website 9 times in a row, the First Byte Time is in some Requests and also in different tests very volatile. You can see that in the following test row:
http://www.webpagetest.org/result/131020...4e14345b9/

Can anyone explain me that behavior? The website runs on a virtual server, is it a topic regarding to customizing the backend?

UPDATE: The solution - especially in my case - was postet at the end of this thread.
Find all posts by this user
Quote this message in a reply
11-01-2013, 02:05 PM (This post was last modified: 11-01-2013 02:09 PM by BITS.)
Post: #2
RE: Volatile test results and sometimes long Time to First Byte Time
No ideas about would the error / performance issue could be? In the meantime I reduced a few HTTP GET-Requests but the problem still exists.

E.g. http://www.webpagetest.org/result/131101...58072497e/
Find all posts by this user
Quote this message in a reply
11-11-2013, 03:48 AM
Post: #3
RE: Volatile test results and sometimes long Time to First Byte Time
Now I switched with most of the sides content to a CDN and the problem sometimes still occur. My provider says, everything is ok (the provider checked it twice in the meantime). But I still have problems with the TTFB.

At the moment the VPS must only handle one(!!) request and is obviously not able to do that in an appropriate way. Any ideas what the problem could be?

Here my last test: http://www.webpagetest.org/result/131110...07a1321b5/

Best
Find all posts by this user
Quote this message in a reply
11-11-2013, 09:27 AM (This post was last modified: 11-11-2013 09:29 AM by robzilla.)
Post: #4
RE: Sometimes Long Time to First Byte Time for the first request
A CDN for your static resources has no effect on the TTFB of your pages. In my experience, it loads well most of the time (all of the time, actually, but your test results clearly indicate otherwise). Perhaps something like a scheduled (cron) job is straining the CPU at intervals, thus interfering with page load times?
Find all posts by this user
Quote this message in a reply
11-11-2013, 01:06 PM
Post: #5
RE: Sometimes Long Time to First Byte Time for the first request
(11-11-2013 09:27 AM)robzilla Wrote:  A CDN for your static resources has no effect on the TTFB of your pages. In my experience, it loads well most of the time (all of the time, actually, but your test results clearly indicate otherwise). Perhaps something like a scheduled (cron) job is straining the CPU at intervals, thus interfering with page load times?
Hi robzilla,

thank you very much for your answer. Yes, I know that the CDN has only an effect on static resources. But if you look in my first post, I had also trouble with the TTFB with static resources on my VPS.

I just monitored my cpu usage via "top -d 1" while doing the wegpagetest.org and I found one point: The long TTFB only occurred once during about 40 tests. And in this moment the ps showed that the command php-cgi will need about 28% of cpu usage.

I think this could be the reason but I have no idea what to do in this case?
Find all posts by this user
Quote this message in a reply
11-11-2013, 07:42 PM
Post: #6
RE: Sometimes Long Time to First Byte Time for the first request
28% shouldn't be a problem unless your share of CPU on this particular VPS is less than or equal to 28% of a full (virtual) core. Also, if it's consistently at 28%, all your requests should suffer from the longer TTFB.

Have you noticed any other patterns? Perhaps it's always the first request that has a longer TTFB? In that case, you could look into how caching is done for your site; perhaps the first request takes longer to process because the cached version is invalidated.
Find all posts by this user
Quote this message in a reply
11-12-2013, 07:45 AM
Post: #7
RE: Sometimes Long Time to First Byte Time for the first request
(11-11-2013 07:42 PM)robzilla Wrote:  28% shouldn't be a problem unless your share of CPU on this particular VPS is less than or equal to 28% of a full (virtual) core. Also, if it's consistently at 28%, all your requests should suffer from the longer TTFB.

Have you noticed any other patterns? Perhaps it's always the first request that has a longer TTFB? In that case, you could look into how caching is done for your site; perhaps the first request takes longer to process because the cached version is invalidated.

Unfortunately I didn't find any other patterns. Before I used a CDN in most of the cases there was a long TTFB for static files like pictures (see test link in my first post). And that's a fact which not fits together with the theory about a caching problem.

Nevertheless I set the cache time in WP Super Cache from 1 hour to 24 hours.

The biggest problem which I don't understand is, that there is also a long TTFB time for static resources if I don't use a CDN.
Find all posts by this user
Quote this message in a reply
11-12-2013, 07:24 PM (This post was last modified: 11-12-2013 10:51 PM by robzilla.)
Post: #8
RE: Sometimes Long Time to First Byte Time for the first request
Could be poor disk performance. When you're testing the site and php-cgi takes roughly 28% of CPU, what's the CPU doing? Is it waiting for the disk? (%wa in top) You can use tools like hdparm (e.g. hdparm -tT /dev/vda1) or ioping to get a basic idea of disk performance, or something like fio for a more thorough analysis.
Find all posts by this user
Quote this message in a reply
11-14-2013, 03:28 PM (This post was last modified: 11-14-2013 03:48 PM by BITS.)
Post: #9
RE: Sometimes Long Time to First Byte Time for the first request
(11-12-2013 07:24 PM)robzilla Wrote:  Could be poor disk performance. When you're testing the site and php-cgi takes roughly 28% of CPU, what's the CPU doing? Is it waiting for the disk? (%wa in top) You can use tools like hdparm (e.g. hdparm -tT /dev/vda1) or ioping to get a basic idea of disk performance, or something like fio for a more thorough analysis.

Thanks again for the answer. I did a few more tests with top again and also ioping. I also temporary deactivated the CDN.

The result was: http://www.webpagetest.org/result/131114...5129e3894/

But there was no high CPU usage and the %wa was all the time 0. The logging with top is a little bit complicated because you get the results only each second. There were also no high ms values via ioping. Sometimes about 15-20ms but that's nothing in comparison to a TTFB of about 1000 ms.

Do you have any other ideas?

Further question: Is there any possibility that this is not a server-side issue? If not, then I will probably change my provider.
Find all posts by this user
Quote this message in a reply
11-14-2013, 06:07 PM (This post was last modified: 11-14-2013 06:08 PM by robzilla.)
Post: #10
RE: Sometimes Long Time to First Byte Time for the first request
Quote:Further question: Is there any possibility that this is not a server-side issue? If not, then I will probably change my provider.

You always seem to use the Falkenstein test instance, so I would suggest trying a few other WPT test locations to see if they show similar results. If they do, then I would probably contact the hosting provider about this first, to see if they might have a clue.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)