Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   Page load time (http://www.programmingforums.org/showthread.php?t=14548)

FireflyX Nov 21st, 2007 3:36 PM

Page load time
 
As of 2 days ago i took the site staticfire.co.uk down. The reason was due to the fact it took extreamly long to load pages and half the time pages weren't loading at all because of the maximum script execution time being reached. Therfore i took the site down untill the problem was sorted. Thing is.. i don't really know what the problem is so i was wondering if anyone could point me in the direction of some websites which show how page loading times can be reduced. The site is done in PHP/MySQL and some Javascript/Ajax. I don't really want to post the script where this is happening because it's 100s of lines long and it seems somewhat impolite asking for people to check huge scripts like that.

I'd like to get this sorted as soon as possible because i have some very impatient users who like bugging me :) any help is appreciated, thanks.

Sane Nov 21st, 2007 4:20 PM

Re: Page load time
 
I think this requires more questions answered:

- What is the ping time on the server?
- What is the ping time on the mysql server?
- How long does it take to serve an .html file of equivilent size?
- Is it all of the scripts that take extremely long? Some of them? Or one of them?
- If it's some of them, is there a common library/function/code that you are using in the scripts that isn't written so efficiently? This may point you to a certain problem, such as a lag in the MySQL server.

Scatter some outputs of the system clock throughout your code and see what parts are taking the most time to execute. Use this to isolate the part of the code that is taking the longest. What is the isolated piece of code?

Jimbo Nov 21st, 2007 4:57 PM

Re: Page load time
 
To expound on Sane's last point, if none of the others are pointing to anything suspicious, you should put a profiler on your code. You probably find one that goes on your backend (PHP) code fairly easily, and then you'll know if something's up on that side. I don't know what tools are available for profiling JavaScript.

Sane Nov 21st, 2007 5:04 PM

Re: Page load time
 
Yes, good call. But a last resort if anything. I have a feeling this guy's problem is very straightforward.

I wouldn't worry about profiling Javascript. JS can't even begin execution until the entire page has finished loading.

Jimbo Nov 21st, 2007 5:07 PM

Re: Page load time
 
Yeah, re-reading his post, it sounds like the PHP engine is timing out. I'd thought maybe the content wasn't coming up from the AJAX sources, but that doesn't sound like it would be the problem anymore.

FireflyX Nov 21st, 2007 6:49 PM

Re: Page load time
 
You guys seem convinced that this is a straightforward problem, i hope you're right :) but i'll report back here tommorow when i've tried out some of your suggestions.

FireflyX Nov 22nd, 2007 12:33 PM

Re: Page load time
 
Ok i have a feeling that it's MySQL that's causing it by having too many connections. The code to connect to MySQL is in the page banner and then i use mysql_close to close any connections in the footer once the page so i don't see how that could cause too many open connections.

null_ptr0 Nov 22nd, 2007 12:37 PM

Re: Page load time
 
Most likely your server is slow.

FireflyX Nov 22nd, 2007 12:48 PM

Re: Page load time
 
I've used the same saerver for a while now and this has only recently started happening. I did manage to find a MySQL query which is for some reason seeming to be running so slow that it's often causing the server to timeout:

:

$result = mysql_query("UPDATE active SET time=CURTIME(),timeout=ADDTIME(CURTIME(), '00:10:00') WHERE loginname='$loginname'") or die(mysql_error());

Now what is strange is that this query is only supposed to be run when you are actually logged in the site but this is definately what's causing all the crashes.

null_ptr0 Nov 22nd, 2007 12:57 PM

Re: Page load time
 
Quote:

Originally Posted by FireflyX (Post 137373)
I've used the same saerver for a while now and this has only recently started happening. I did manage to find a MySQL query which is for some reason seeming to be running so slow that it's often causing the server to timeout:

:

$result = mysql_query("UPDATE active SET time=CURTIME(),timeout=ADDTIME(CURTIME(), '00:10:00') WHERE loginname='$loginname'") or die(mysql_error());

Now what is strange is that this query is only supposed to be run when you are actually logged in the site but this is definately what's causing all the crashes.

Hmm, that's strange.


All times are GMT -5. The time now is 3:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC