Page 1 of 1
PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 10:05 am
by nutkenz
Whenever I'm logged out of my session (which I also can't explain why it's happening) and reload the page, it takes about 3 full minutes for it to load, even though the PEAR timer claims otherwise:
Code: Select all
time index ex time %
Start 1215786404.88426100 - 0.00%
Auth: Start 1215786404.91293000 0.028669 50.09%
Auth: Finish 1215786404.91962200 0.006692 11.69%
ACL: Start 1215786404.91989000 0.000268 0.47%
ACL: Finish 1215786404.91994300 0.000053 0.09%
Stop 1215786404.94149500 0.021552 37.66%
total - 0.057234 100.00%
There's hardly any code being executed though... what could be causing this? It's not my internet connection because it's also happening on my localhost WIndows test server. Both servers run Apache.
Re: PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 10:12 am
by s.dot
Are you on a shared server? It may be severely overloaded.
Re: PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 10:52 am
by nutkenz
No, it's a dedicated server and it's not overloaded at all; the load is 0.18 / 4 on a Dual Core AMD Opteron(tm) Processor 270
Also, it's happening on my local Windows testing environment as well so it is probably not hardware related. I'm not sure where to start looking for the issue because the timer reports that the site is being processed in less than a second... I'm wondering why it takes the browser that long to process.
Re: PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 12:19 pm
by s.dot
Ping your servers and check the response times.
Post the code you're using.
Hm... don't really know what else to try. =/
Re: PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 12:59 pm
by nutkenz
Here's the code which is involved when the session has expired and the login layout is called:
Project dispatcher (index.php):
Code: Select all
$page = $p["path"].".php";
// Access control
if (@$_REQUEST["logout"])
{
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
flash(trl("You have been logged out."),"/admin");
}
elseif (!ALLOW_ACCESS)
{
if ($userLogin = user("login"))
{
$msg["error"]->add(trl("$userLogin is not allowed to access this page.
Please upgrade to an account with higher security clearance."));
}
$p["layout"] = "none";
include(LIB_LAYOUTS_PATH."login.php");
}
elseif (strstr($page,"pages") === false)
{
// If we're not including a standard page (cron job) -> get output only
$html = getData($_SERVER["HTTP_HOST"]."/".$page."?".$_SERVER["QUERY_STRING"]);
}
else // Process PHP page
{
ob_start();
include($page);
$html = ob_get_contents();
ob_end_clean();
}
$admin = true; // Use admin templates
include(LIB_DRIVERS_PATH."dispatch.php");
Library dispatcher (called at the end of the previous file):
Code: Select all
if (!empty($p["html"]))
{
// Replace standard HTML
$html = $p["html"];
}
if (!empty($p["layout"]) && $p["layout"] !== "none")
{
$customLayout = LAYOUTS_PATH.$p["layout"].".php";
if (file_exists($customLayout))
{
include($customLayout);
}
else // There is no custom layout defined
{
include(LIB_LAYOUTS_PATH.$p["layout"].".php");
}
}
else echo @$html;
if (VERBOSE >= 2)
{
$timer->display();
}
Auth.php:
Code: Select all
<?
$timer->setMarker("Auth: Start");
require_once('Zend'.DS.'Auth.php');
require_once('Zend'.DS.'Auth'.DS.'Storage'.DS.'Session.php');
require_once('Zend'.DS.'Auth'.DS.'Adapter'.DS.'DbTable.php');
$auth = Zend_Auth::getInstance();
$session = new Zend_Auth_Storage_Session("user");
$auth->setStorage($session);
$authDb = new Zend_Auth_Adapter_DbTable($db,'users','login','pass');
if (!empty($_REQUEST["auth_login"]))
{
$login = $_REQUEST["auth_login"];
$pass = $_REQUEST["auth_pass"];
}
else // No login attempted
{
$login = $pass = null;
}
if (!empty($login) && !empty($pass))
{
$authDb->setIdentity($login)->setCredential($pass);
$result = $authDb->authenticate();
if (!$result->isValid())
{
foreach ($result->getMessages() as $message)
{
$msg["error"]->add(trl($message));
}
// Invalidate existing data
$auth->clearIdentity();
}
else // Logged in
{
Zend_Session::rememberMe(60*60*24*7);
$auth->getStorage()->write($authDb->getResultRowObject(null,'pass'));
}
}
$timer->setMarker("Auth: Finish");
Re: PHP page taking 3 minutes to load
Posted: Fri Jul 11, 2008 6:18 pm
by Benjamin
Have you checked for a load spike whenever a request is pending? That would indicate a faulty loop of some sort. Someone else was having this problem a while back and I believe they were using Zend as well. I don't believe there was a solution posted.
Re: PHP page taking 3 minutes to load
Posted: Sat Jul 12, 2008 3:17 am
by nutkenz
There is no spike in the load.
Re: PHP page taking 3 minutes to load
Posted: Sat Jul 12, 2008 1:19 pm
by nutkenz
Any more suggestions on possible solutions to the long loading time?