WebPagetest Forums

Full Version: Very long TTFB (16 seconds) help please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I tested my webpage with webpagetest and got following results:
http://www.webpagetest.org/result/120824_ES_M3E/

I get very high time to First Byte value.
I checked for static content (for example a jpeg file or css file) they are loaded very fast. So server is ok.
But main page is received very slow.
I use CakePHP framework.

I would be happy if you can give information about how can I find the bottleneck. Thank you.
you need to check what kind of tiers involved in generating the subjected page? In general, if it is a dynamic page, then problem is either application server or database server. you need to check/troubleshoot your webserver if TTLB is more.

Thanks,
Barath K
Are you running on a shared host or is it a VPS/Dedicated server? If you have access to install software then I'd recommend installing New Relic which will tell you pretty quickly where your back-end bottlenecks are.

If you can't install New Relic then you pretty much have to add instrumentation to the app directly to time different operations to see where the time is going. Odds are it is time spent doing database queries or calling out to an external web service. Could be a single really slow call or a whole lot of slightly slow calls adding up.
(08-27-2012 10:09 PM)pmeenan Wrote: [ -> ]Are you running on a shared host or is it a VPS/Dedicated server? If you have access to install software then I'd recommend installing New Relic which will tell you pretty quickly where your back-end bottlenecks are.

If you can't install New Relic then you pretty much have to add instrumentation to the app directly to time different operations to see where the time is going. Odds are it is time spent doing database queries or calling out to an external web service. Could be a single really slow call or a whole lot of slightly slow calls adding up.

I use shared hosting but it is a high performance server and I have one %100 CPU.
Unfortunately I don't have access to shell.
In my homepage there exists no database call. I have external web services in homepage as blocks but I cache the results of that block for one hour and serve cached that output for one hour.

Any help will be appreciated.

I'm also curious about the visitors.
Averagely I have 20-25 visitors in my website constantly.

Another interesting point, when I put tic toc before and after my application code I get 0.1-0.3 seconds output.
But when I try to reach the same page from browser, I can see the page on my browser in 10-15 seconds.
Assuming tic toc is something that measures the application response time (sorry, not familiar with it) then it sounds like the web server is over it's capacity. If the server is running out of clients to process inbound requests it has to hold on to the request until one frees up. I see this on Apache a lot when persistent connections are enabled because each connection ties up a client even when it isn't doing anything but sitting there.

Assuming the shared hosting provider is responsible for the web server config I would open a ticket with them to investigate.
I put an empty file to my server.

File name is "foobar.php". Its content is as follows:

Code:
<?php
echo "hello world";
But when I try to enter to example.com/foobar.php, I get

DNS 203 mseconds
Connect 3.33 seconds
Send 0 miliseconds
Time to First Byte 17.35 seconds
Receive 1 miliseconds Total load time 20.88 seconds

Then I put another file called "foobar.txt". Its content is as follows:

Code:
hello world<br/>
Loading time of foobar.txt is approximeately 0.2 seconds.

This website is inside a shared hosting so I can't get a root Linux access. I'm trying to find out what makes my site slow.
  • When I get these results I have 60 visitors in my site. And they send AJAX requests when they are active. When they are active they send an AJAX request nearly every 3 seconds.
  • Generally my website has 5-20 requests per second.
  • My hosting provider says that there occurs no CPU overload, it is very low generally.
  • I asked hosting company for Apache limits. I get this values for the whole shared server:
    MaxClients 300
    MaxRequestsPerChild 4000
    ThreadsPerChild 25
  • example.com/mybigpage.php and example.com/foobar.php pages are opened nearly at the same time.
  • If page has txt, jpeg or other extensions they are opened instantly. If extension is php it opens very slow.

New Edit: I talked with my hosting company. And told them that "foobar.php" is opened nearly in 20 seconds. Although that file has no code at all. They told me that they put "foobar.php" to other websites that we use same server. I also tried "othersite.com/foobar.php". It opened instantly. But "mysite.com/foobar.php" opened nearly in 15 seconds. What would make this behaviour? We use same PHP configuration with other sites, but they open instantly.. Can it be because of my .htaccess rules? Or other thing?

New Edit2: My provider told me that there exists no "apd.so" file inside the server. So it seems like I can't use APD.

What should I look for to find the bottleneck?
What would limit my site?
What do your .htaccess rules look like? If the rules are causing the php code to try an expensive operation before falling back then it's certainly possible that they are the cause of the issues.

That said, the 3 second connect time may be an outlier or a sign of a significant problem. Can you try running several tests (say, 9 runs) and see if it is consistently slow or if it was just an outlier?

3 seconds is the retransmit time for Windows when packets are lost during socket connect so if the provider has a packet loss problem then you could see that happen intermittently. It can also be a sign of an apache server that has run out of clients to handle connections. Do you know if php is configured as a fastcgi or how it is running in apache? It could also be something specific to your php environment if they allow each user to have custom php.ini settings (or something with launching the cgi processes).

  1. My htaccess is as follows:
    Code:
    <FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
    Order allow,Deny
    Deny from all
    </FilesMatch>

    <IfModule mod_rewrite.c>
        RewriteEngine On

        RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
        
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
  2. 3 second of connection is an outlier. I get that much of time not so frequent. Generally 0,2 seconds connect time. But TTFB is very long.
  3. I asked about MaxClients value of Apache they said it is 300. And when my site was very slow in evening hours, I asked my provider about server load. They said that server load is very very low at that time and no limit is reached.
  4. Not fastcgi. My PHP is running as Apache module.



(01-02-2013 11:19 PM)pmeenan Wrote: [ -> ]What do your .htaccess rules look like? If the rules are causing the php code to try an expensive operation before falling back then it's certainly possible that they are the cause of the issues.

That said, the 3 second connect time may be an outlier or a sign of a significant problem. Can you try running several tests (say, 9 runs) and see if it is consistently slow or if it was just an outlier?

3 seconds is the retransmit time for Windows when packets are lost during socket connect so if the provider has a packet loss problem then you could see that happen intermittently. It can also be a sign of an apache server that has run out of clients to handle connections. Do you know if php is configured as a fastcgi or how it is running in apache? It could also be something specific to your php environment if they allow each user to have custom php.ini settings (or something with launching the cgi processes).
You are on a shared server running mod_php? Do you have a dedicated Apache for your site?

mod_php and the worker MPM are not supposed to be used together ( http://www.php.net/manual/en/faq.install...on.apache2 ). I have never been able to scale apache with mod_php well because you generally need 1 client for each connection for as long as the connection is alive (keep-alive makes that a nightmare).

Running out of available clients would quite easily explain what you are seeing. If you aren't running a worker MPM then ThreadsPerChild isn't really kicking in and you can only handle 300 maximum connections at a time (and each browser can be opening as many as 6 of those so 50 simultaneous users).

webpagetest.org used to run on Apache with the prefork MPM but I was having a tough time getting it to scale well. I gave up entirely on Apache as a result and now run Nginx + php-fpm and the difference was night and day.

I can't help but think that your hosting provider either doesn't know what to look at or is confused about the information they are providing you.
* I'm on a shared server. That's why I can't try APD for PHP Sad

* In my hosting options there exists these options:
  • Apache module
  • FastCGI application
  • CGI application
Is it better to try FastCGI ? But when I said my provider to switch to FastCGI, they said that Apache gives error.

* I don't know whether they use worker MPM as well. If it is important I can ask them or check it?

* My provider can't give me satisfactory support for this issue. But I don't want to change my provider. So I'm trying to diagnose the problem. Also because they say that server load is very low. If I can solve this issue than my site can fly Smile



(01-04-2013 06:06 AM)pmeenan Wrote: [ -> ]You are on a shared server running mod_php? Do you have a dedicated Apache for your site?

mod_php and the worker MPM are not supposed to be used together ( http://www.php.net/manual/en/faq.install...on.apache2 ). I have never been able to scale apache with mod_php well because you generally need 1 client for each connection for as long as the connection is alive (keep-alive makes that a nightmare).

Running out of available clients would quite easily explain what you are seeing. If you aren't running a worker MPM then ThreadsPerChild isn't really kicking in and you can only handle 300 maximum connections at a time (and each browser can be opening as many as 6 of those so 50 simultaneous users).

webpagetest.org used to run on Apache with the prefork MPM but I was having a tough time getting it to scale well. I gave up entirely on Apache as a result and now run Nginx + php-fpm and the difference was night and day.

I can't help but think that your hosting provider either doesn't know what to look at or is confused about the information they are providing you.
Pages: 1 2
Reference URL's