Slow response due to PHP processing?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
xterminator
-


Joined: 30 Jan 2007
Posts: 1

PostPosted: Tue Jan 30, 2007 10:52 am    Post subject: Slow response due to PHP processing? Reply with quote

Hi,

I'm currently developing a PHP application that runs on localhost. In the early stages, the server response we're really fast (I'm using Abyss Web Server w/php 5.2.0 and mysl 4.1 on windows xp), but as the project evolved, it got more and more slowly.

If I request a page from the server, it can take as long as 20-30 sec before it responds. First I though it was my coding, but when using microtime to measure PHPs rendering speed, it took less than a second.

I then tried to disable all my network connections so no connection to the Internet was present... and BANG! The speed was back! As soon as I connected to the Internet again it wen't slooooooooow.

And then I started to think; I have serveral ajax requests that again calls a PHP page who connects to a remote server via fsockopen. As far as I can tell, this must be the problem, but then a new question arised:

- Dosn't the web server cancel my connection/request/script execution to a page when I reload/request another page? Correct me if I'm wrong.

My own conclusion is that my local webserver dosn't (detect and) terminate the ongoing ajax (fsockopen requests from PHP to the remote site), but wait's for them to complete and hence slows my application down.

If this is the cause, is there any way to cancel ALL ongoing connections when I request a new page from the localhost server so I can avoid this problem?



Thanks in advance.
- Mads
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Jan 30, 2007 3:50 pm    Post subject: Re: Slow response due to PHP processing? Reply with quote

xterminator wrote:
- Dosn't the web server cancel my connection/request/script execution to a page when I reload/request another page? Correct me if I'm wrong.


That's how CGI/FastCGI works. The server waits for an explicit end of the script (or until the execution times out). The server does not kill the script when you stop loading the page from the browser because it could be dangerous and let your databases or files (if you write to them) in an unstable state.

From what we understand here, it's the fsockopen() that is causing this long delay. Either rewrite your script to have a better way to read and stop the script after a reasonable amount of time, or you could try at least to increase the number of simultaneous connections of Abyss Web Server (in Server Parameters > General ).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
wishbone42
-


Joined: 05 Mar 2007
Posts: 2
Location: Bracknell, UK

PostPosted: Mon Mar 05, 2007 11:26 am    Post subject: Reply with quote

Hi,
I don't believe that it's necessarily an issue with any particular function call. I've encountered a similar problem, but with an upgrade from PHP 5.1.1 to PHP 5.2.1, using the same web application.
I believe there's something in the PHP 5.2.1 msi installation which is introducing the problem, as it doesn't go away when you revert back to PHP 5.1.1.
I've been able to verify this, as I have two identical machines and the one upon which I didn't run the upgrade is fine. Another thing I noted was that the date on the the 'etc\hosts' file changed, but there's no indication what changed (and why would it have been anyway!). Regretably, creating a new one from scratch in case a special character had been introduced doesn't resolve the issue either. Another oddity is that the HTTP Server (Apache 1.3 - Oracle HTTP Server) takes many seconds longer to start when connected to the network.
It all points towards a change in the way name resolution works when connected and not connected to a network, but beyond the etc\hosts file I'm afraid that's outside my baillewick.

Any ideas?
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Mar 07, 2007 5:31 pm    Post subject: Reply with quote

wishbone42 wrote:
It all points towards a change in the way name resolution works when connected and not connected to a network, but beyond the etc\hosts file I'm afraid that's outside my baillewick


PHP does not alter etc/hosts (unless you explicitly write a script to do so). That file is usually modified by AdBlockers and PopUp blocking software. We suggest that you check your system for such "goodies", disable them, and test the speed. We also strongly recommend that you scan it for spyware or other malware.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
wishbone42
-


Joined: 05 Mar 2007
Posts: 2
Location: Bracknell, UK

PostPosted: Thu Mar 08, 2007 9:48 pm    Post subject: Reply with quote

Thanks for your response. I'll check those things, but it remains a puzzle as to why response to localhost is very slow when connected to a network, yet it returns to normal immediately it's disconnected. One would imagine it must have something to do with name resolution.
Best regards,
Back to top View user's profile Send private message
Vesku
-


Joined: 13 Nov 2006
Posts: 11

PostPosted: Sun Aug 19, 2007 1:01 pm    Post subject: Reply with quote

I had exactly the same problem.

Check your DNS servers with ipconfig /all. If your DNS ip is the same as your modem ip, this might be the problem.

Solution:
Change your ISP's DNS servers manually to your computer network settings. This helped for me.

Some modems (e.g. A-Link) acts like a DNS server in NAT mode.

I think this problem occurs only with Windows XP Home -version and with this type of modem.

I installed wireshark and found out, that XP Home sends DNS query:
SRV _LDAP._TCP (without the domain name) when trying to connect to localhost and the modem's DNS server can not respond to this correctly. (Should respond: No such name). This is causing the delay.

Hope this helps,
Br. Vesku
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group