Jump to content

Really Slow Response Times


Recommended Posts

I'm using PHP+MySQL to build a CMS. Its going pretty well. I have one problem...

 

The CMS uses mod_rewrite to change www.site.com/section/page into GET vars. Sometimes, I have a folder like www.site.com/xml - this contains an index.php, and then different pages get included depending on the URL, eg

 

www.site.com/xml/newsfeed

 

includes the newsfeed.php file in the xml folder. This is fine. But I have a flash file that simultaneously requests 4 files from the xml folder, which basically calls index.php 4 times with different included pages, all using the CMS to generate the content.

 

I seem to get really bad performance sometimes. Sometimes it will load straight away, but then it seems if i reload the page it will take 30+ seconds sometimes. Its weird, in firebug the net monitoring shows the requests, it usually loads a couple of the xml/filename files, but i dont see the other 2 even tho the first couple are done...

 

Also, i put some speed tester code in the php's and they all say they take something like 0.02 seconds to generate...it just seems to take ages to get back to the browser or something.

 

Each call to xml/file opens the index.php in /xml, which then looks in the cache folder to see if xml/file has been cached yet, if so it echos its contents, else it connects to the database, generates the content, creates the cached file, then echos it out

 

Any ideas why the bottlenecks are occuring?

 

The site is http://mamajazz.com.au/

Link to comment
Share on other sites

Its been suggested this could be to do with mod_rewrite. The rule im using is

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?section=$1&page=$2 [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?section=$1&section2=$2&page=$3 [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?section=$1&section2=$2&section3=$3&page=$4 [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php

 

My other thought is - could it be some unclosed connection to a database or some unclosed link to a dir/file - something like that??? Can anyone offer any tips of common things to ensure are done to properly terminate a script

 

im using mysql connections, reading contents of files, writing files, using output buffering, and using sessions. im also using register_shutdown_function to do things like close sessions and close output buffers...

Link to comment
Share on other sites

My cms uses mod rewrite to refilter all request that end in .php to my index page

so

mysite.com/stuff/page1.php goes to

mysite.com/index.php?page=stuff/page1.php

 

and then it prepares content outta a database based on the get variable $_GET['Page'];

 

the mod looks like

Options +FollowSymLinks
Options +Indexes 
RewriteEngine on

RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !=/htdocs/index.php [NC]
RewriteRule ^(.+)\.php$ index.php?Page_Request=$1&request=1 [QSA,L]     

RewriteRule ^$ index.php?Page_Request=index&request=1 [QSA,L]     
  

 

Note the RewriteCond you can exclude files you want from the rewrite rule allowing you to bypass folders you want to bypass

 

Hope it helps gives you an idea.

 

Note this only rewrites files ending in .php so a .xml file is safe

Link to comment
Share on other sites

its not that i dont want files in the xml folder to be rewritten - in fact i do.

 

what im asking is - is theres something wrong with the mod_rewrite rules i posted, or should they work ok. if they are ok, what could be causing this massive lag in request response despite the fact in the response the timer says the php took mere milliseconds to generate?

Link to comment
Share on other sites

Hmmm someone mentioned it could be to do with PHP SESSIONS...

As long as a php session is opened, no other scripts are allowed to open the same session (to avoid threading issues with the session data), and PHP will block on any call, even an implicit one, to open that session. Using sessions can cause slow loading behavior if you're including lots of php-served files into the same parent page. In some, rare, cases with web services calling eachother I've even seen php grind to a halt completely until the request timed out.

This is what im doing - using sessions for lots of php created pages using the same parent php page...

 

Any ideas how to get around this? I need the session open on each one so i can write to it throughout the script execution, so what i was doing was

session_start();
function sessionCloseFunc(){
session_write_close();
}
register_shutdown_function(sessionCloseFunc);

Is there a way to have 'shared' sessions for a parent page? or something like that???

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.