Yes It Is Fast? (Solved)

Hi,

I’ve put this in the footer of my page.


<?php echo Yii::getLogger()->getExecutionTime(); ?>

I’m working in an Yii application generated by Gii and modified by me just a little. No special or very complex thing done or extensions loaded. Yet is takes 1.1 second to generate the page. Except from the default static pages from the SiteController that one takes just 0.03 sec.

I’ve disabled test modus in the index.php




// remove the following lines when in production mode

// defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

// defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);



And i’ve activate the cache function:




// application components

'components'=>array(

   'cache'=>array(

     'class'=>'system.caching.CFileCache',

   ),



But it makes no difference at all?

Or is it normal that an admin overview of a table with 10 records takes 1.1 second to generate? I wonder if my server can handle this if there are a lot of requests per second. :(

edit: OMG just found the profiling option:




'log'=>array(

  'class'=>'CLogRouter',

  'routes'=>array(

  array(

    'class'=>'CFileLogRoute',

    'levels'=>'error, warning',

  ),

  // uncomment the following to show log messages on web pages. -> tnx i just did!

  array(

    'class'=>'CWebLogRoute',

  ),



And this tells me the system.db.CDbConnection took allmost a second. Gonne find out why…

bjorn definitely something wrong, it should be very long it should milliseconds not seconds

Replace ‘localhost’ with ‘127.0.0.1’ in your config file (protected/config/main.php).

‘connectionString’ => ‘mysql:host=127.0.0.1;dbname=…’

:blink: … Tnx! :D

Must be a newbie thing i guess? Tnx again for pointing this out!

0.078 sec, i can live with that. Yes it is fast (again)!

Why does this have this big an impact? I’d like to understand why…

I’m a newbie to networking, but on our last course teacher was more than convinced that both localhost and 127.0.0.1 are aliases of local network card loopback.

Sometimes they’re called echo addresses, as all the network activity sent to any of these two addresses doesn’t actually leave local computer, isn’t injected into network and is all processed by local network card.

These two adresses are resolved at lowest or one of lowest layers of layered network model, so virtually they’re equal, similar and the same.

So, if you observe such significant changes between using these two addresses, I would be more than convince, that you should check configuration of your:

  • network card,
  • system (Windows?),
  • webserver (Apache?),
  • eventually PHP parser.

And only after that to blame Yii or your own PHP code.

In other words, I would be very, very surprised, if you could prove, that source of this problem is at language level, not at hardware or system level.

This link offers one explanation:

http://stackoverflow.com/questions/11310564/php-to-easyphp-mysql-server-1-second-connection-delay/15436435#15436435

+1 for coming out with a link to a nice article.

However, if I understand this article correctly, this is only Windows-related problem. And that would mean, that this occurs only at development level, because you would have to be crazy to host your production version application on Windows, right? :]

:lol: :lol: :lol: :lol: :lol: :lol: so right

And having a windows dev server and a linux production server doesn’t make much sense either

Why?

I’m working this way for years! With only small exception that I don’t own production server, only I use shared hosting. But it does it on Linux and my dev environment is on Windows. I don’t see, why you find this not productive? :]