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.
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.
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:
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:
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).
[*]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.
[*]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.
[*] Not fastcgi. My PHP is running as Apache module.
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
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
If so then you can query (or even plot over time) the apache stats and that should give you an idea if you are running out of clients. Running out of available clients will not show up in the server load stats and if they are running their business on hosting websites they should at least be able to monitor the available clients and tell when the server config is out of capacity.