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 have a Linux server (Ubuntu 10.04) running apache2 and PHP. Everything runs fine when accessing a page from any browser from another Linux machine or Mac. But when I try to access a page from any combination of Windows machine and browser I get about a 30 second delay before the page comes back. Accessing a plain old HTML file from the Windows browser runs lickity split. So it seems to be just PHP. MySQL is installed but a simple test page that uses no MySQL is still slow.

I don't think it is DNS because if I hard code the IP address in the URL nothing changes. There doesn't seem to be anything in the log files that I can tell.

What could be causing this behavior on Windows clients?

share|improve this question
    

1 Answer 1

Update: some "3rd base" debugging tips;

A fairly brutal way to get some debugging is to strace the running apache process, and this is actually easier because the processes are going to be hung for a while.

This command below will only work as stated if your apache is in prefork mode, but I would assume that it would work vaguely similar in worker mode. (but you would have to spend some time getting a ps and grep to find the thread ids...) anyway I think php requires prefork...

First check that the server is in prefork mode...

root@server-72839:/home/ubuntu# apachectl -V | grep MPM
Server MPM:     Prefork             <----------- prefork mode works with php
 -D APACHE_MPM_DIR="server/mpm/prefork"

install strace

root@server-72839:/home/ubuntu# apt-get install strace

make some request to the server, and then run the following command to trace the syscalls made by the hung process;

 root@server-72839:~# netstat -antp | grep "ESTABLISHED" | grep 80 | while read _ _ _ _ client _ proc; do strace -f -p ${proc#/*} &  done



root@server-72839:~# Process 21570 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
chdir("/")                              = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabb16b0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabb16ae000

let the page request run through on a windoze box that is slow and then paste all that output back into a pastebin and put the link in a comment.

If you don't have any joy with this, then turn on debugging of php, and httpd Loglevel to debug and paste all that into a pastebin and provide the link....


Edit: (ok maybe not definitely) possibly a reverse DNS problem on the apache server. try the following....

make sure you have set HostnameLookups Off on your apache server.

http://httpd.apache.org/docs/2.2/mod/core.html#hostnamelookups

Also check that your resolv.conf is specifying working nameservers;

[root@workstation001 /root]# cat /etc/resolv.conf 
....
nameserver 192.168.1.254       <---- this must work. test it with dig

test nameserver with dig;

 [root@workstation001 /root]# dig @192.168.1.254 www.google.co.uk +short
 www-cctld.l.google.com.
 173.194.67.94

make the nameserver work, by changing it to 8.8.8.8 (google public dns server)

/etc/resolv.conf

 nameserver 8.8.8.8
 nameserver 8.8.8.4

Start by checking out the php.log and apache logs files for the connections which are slow, the problem is likely right there in logs.

However if you are sure that this is not a DNS problem (which you can check using the nslookup command line tool) and there is nothing obvious server side then I would then use google chrome in-built developer tools to see the timeline of the page load.

This will tell you which item in the page is taking so long, and whether the delay is during the connection, or during resource loading etc.

You can move on to tools like wget, curl in cygwin, or plain telnet to further investigate from the client side.

enter image description here

share|improve this answer
    
Thanks. On the client nslookup worked fine and sees the server. In the Chrome timeline all I see are big time gaps on the Send Request and Receive Response !Chrome Timeline –  Ed Harcourt Mar 20 '12 at 19:20
    
A wget on a PHP page from Windows takes over 20 seconds for a file that simply says <?php echo 'hello'; ?>. It is always just waiting for a response from the server. If the file has no php in it then is is fast. –  Ed Harcourt Mar 20 '12 at 19:54
    
man, that is so to do with DNS. make sure you have HostnameLookups Off in your httpd.conf, put that in your virtualhost as well just to make sure. –  Tom H Mar 20 '12 at 23:10
    
i bet 20 quid this is something to do with DNS on the server side. –  Tom H Mar 20 '12 at 23:19
    
I'll give it a shot first thing in the morn. Thanks. –  Ed Harcourt Mar 21 '12 at 0:40

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.