4

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?

1
  • Apache running what? Static files? PHP? Ruby? Python?
    – devicenull
    Apr 28, 2012 at 23:30

3 Answers 3

4

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.

3
  • I just checked and it's already off, so unfortunately that isn't the problem. Apr 28, 2012 at 21:33
  • it looks like dtrace is the mac OS equivalent of strace - troeger.eu/cms/?p=255
    – Tom
    Apr 28, 2012 at 22:26
  • worked for me. I used the web dev tools in firefox though. same diff. I had forgotten about some dev stuff which I hadnt completed. it was taking 34 secs to load.
    – j0h
    May 27, 2015 at 15:26
4

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

1
  • Glad you resolved the issue. Please be sure to mark your answer as "accepted" when you are able.
    – jscott
    Jul 20, 2012 at 0:33
0

It may stem from mysql connection too. Yo can control it by taking connection string to top of your php page and add return false before connection string then test it i wheather it is ok or not .

If the problem is due to the mysql slow connection you can solve the problem like this.:

If you closed mysql to network, I mean if you activated bind-address="127.0.0.1" in my.ini under [mysqld]. You should also open for ip6 bind-address = ::1

# Change here for bind listening
bind-address="127.0.0.1" 
# for ipv6
bind-address = ::1    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .