Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 21st, 2007, 2:36 PM   #1
FireflyX
PHP God
 
FireflyX's Avatar
 
Join Date: Nov 2007
Location: Stockton, England
Posts: 15
Rep Power: 0 FireflyX is on a distinguished road
Send a message via MSN to FireflyX
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.
FireflyX is offline   Reply With Quote
Old Nov 21st, 2007, 3:20 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,890
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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?
Sane is online now   Reply With Quote
Old Nov 21st, 2007, 3:57 PM   #3
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 766
Rep Power: 3 Jimbo is on a distinguished road
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.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Nov 21st, 2007, 4:04 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,890
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is online now   Reply With Quote
Old Nov 21st, 2007, 4:07 PM   #5
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 766
Rep Power: 3 Jimbo is on a distinguished road
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.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Nov 21st, 2007, 5:49 PM   #6
FireflyX
PHP God
 
FireflyX's Avatar
 
Join Date: Nov 2007
Location: Stockton, England
Posts: 15
Rep Power: 0 FireflyX is on a distinguished road
Send a message via MSN to FireflyX
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 is offline   Reply With Quote
Old Nov 22nd, 2007, 11:33 AM   #7
FireflyX
PHP God
 
FireflyX's Avatar
 
Join Date: Nov 2007
Location: Stockton, England
Posts: 15
Rep Power: 0 FireflyX is on a distinguished road
Send a message via MSN to FireflyX
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.
FireflyX is offline   Reply With Quote
Old Nov 22nd, 2007, 11:37 AM   #8
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 94
Rep Power: 1 null_ptr0 is on a distinguished road
Re: Page load time

Most likely your server is slow.
null_ptr0 is offline   Reply With Quote
Old Nov 22nd, 2007, 11:48 AM   #9
FireflyX
PHP God
 
FireflyX's Avatar
 
Join Date: Nov 2007
Location: Stockton, England
Posts: 15
Rep Power: 0 FireflyX is on a distinguished road
Send a message via MSN to FireflyX
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.
FireflyX is offline   Reply With Quote
Old Nov 22nd, 2007, 11:57 AM   #10
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 94
Rep Power: 1 null_ptr0 is on a distinguished road
Re: Page load time

Quote:
Originally Posted by FireflyX View Post
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.
null_ptr0 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
way to make a function execute at time 'x' badbasser98 C++ 10 Apr 5th, 2006 7:14 AM
VB.net SQL query load time Driest Visual Basic .NET 4 Feb 17th, 2006 6:02 PM
Page Replacement Program (C++) redhatter Existing Project Development 1 Nov 20th, 2005 10:38 AM
Time ChronicCode Java 2 Aug 11th, 2005 2:22 PM
How do i load files to a page crawforddavid2006 HTML / XHTML / CSS 6 Jun 28th, 2005 11:59 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:23 PM.

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