I am running an apache web server on debian 6.0 with kernel 2.6.32-5-amd64.
In certain times of the day, usually when more people are online, the server have very slow responses. I am sure, that is not load, it is not DB, it is not PHP, accualy this command:
time wget 127.0.0.1
is quite slow:
--2013-09-20 15:36:49-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-09-20 15:36:52 ERROR 404: Not Found.
real 0m2.663s
user 0m0.004s
sys 0m0.004s
Response time is up to 5sec. The point of waiting is after "HTTP request sent, awaiting response..." Page generating after this lag common for all http requests is fast, like 50ms.
I tested my web using http://tools.pingdom.com/fpt/, first response is always slow, most of content load is also slow but few are quite fast, but I cannot tell, if this tool have some sort of cache.
telnet 127.0.0.1 80
is fast, the response show without delay:
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Where can be the problem? It must be something before the request goes to apache.
Please tell me at least about some debugging tools for this.
Resolving localhost... 127.0.0.1 Connecting to localhost|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2013-09-23 08:11:15 ERROR 404: Not Found.
real 0m0.003s user 0m0.004s sys 0m0.000s
– Maťo Urbašík Sep 23 '13 at 06:12I dont think the bottleneck is PHP. As I wrote, Im sure PHP scripts is fast, it also means DB queries. First thing in my PHPs is get microtime(), last is get microtime() again and write difference out. When request took 3 seconds, PHP generating with all the quesies is like 50-100ms.
I also dont think the bottle neck is Apache. I added %T/%D to the access log, but in log, even when request is slow, it is always something like 0/42904
– Maťo Urbašík Sep 23 '13 at 07:02