Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running Apache locally on my MacBook Pro, which runs OS X Lion. Up until recently, the server has responded fine. Now, however, it seems to be slow to respond.

I made a request to visit a virtual host on my machine at 22:17:00. Apache did not start responding until 22:17:10. I checked my Apache logs and this is all there is:

127.0.0.1 - - [28/Apr/2012:22:17:10 +0100] "GET / HTTP/1.1" 304 -

There doesn't seem to be anything holding it up that I can see from the access_log, and there are no errors in error_log.

This happens every few minutes, with intervals of normal speed responses in-between. Most notably when a connection has not been made in the last couple of minutes.

Does anyone have any ideas why this might be happening?

share|improve this question
    
Apache running what? Static files? PHP? Ruby? Python? –  devicenull Apr 28 '12 at 23:30
add comment

2 Answers 2

Using chrome developer tools (ctrl-shift-I) you can get an idea exactly at what stage the browser is hanging like so;

enter image description here


Also, you can start httpd under strace to watch exactly what it is waiting for (not sure what the equivalent OS X lion commands would be...)

# strace -t -T -f /usr/sbin/httpd -X -f /etc/httpd/conf/httpd.conf
23:19:35 execve("/usr/sbin/httpd", ["/usr/sbin/httpd", "-X", "-f", "/etc/httpd/conf/httpd.conf"], [/* 29 vars */]) = 0 <0.000008>
brk(0)   
.
.
.

Obviously there will be quite a bit of output, but as your page is hanging for 10 seconds, you should have ample time to cut and paste the syscall that is taking 10 seconds.


You might want to check that HostnameLookups has been disabled in httpd.conf file;
http://httpd.apache.org/docs/2.1/mod/core.html#hostnamelookups

When that is set to "on" httpd tried to do a DNS lookup for every incoming request, and this can be slow if your local naming is not working correctly, or are on an unreliable connection.

share|improve this answer
    
I just checked and it's already off, so unfortunately that isn't the problem. –  Oliver Joseph Ash Apr 28 '12 at 21:33
    
it looks like dtrace is the mac OS equivalent of strace - troeger.eu/cms/?p=255 –  Tom H Apr 28 '12 at 22:26
add comment
up vote 0 down vote accepted

I found my problem here: http://stackoverflow.com/a/7553256/1082754

share|improve this answer
    
Glad you resolved the issue. Please be sure to mark your answer as "accepted" when you are able. –  jscott Jul 20 '12 at 0:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.