Impossible to get PHP Yii waiting TTFB time under

2019-08-24 12:17发布

I created Yii2 basic app https://www.yiiframework.com/doc/guide/2.0/en/start-installation but the index.php waiting time (TTFB) always is around 2s, no less, download time is around 43ms and all the other resources of the default app (CSS, JS) are donwloaded withing 10ms (all as observed from Google developer tools), that is fine. I am running everything on my development machine Windows 10 4GHz, 16GB RAM, low resrouce consumption.

I am adding the xDebug profiling results of index.php call: Results ordered by Incl. and Results ordered by Self.

It can be seen that there is no single slow PHP function, though it is shown that 50% of the self-time is consumed by php::fclose my experiments show that commenting out those two lines only marginally improves the situation. So - it is quite hard to rely on xDebug profiling.

I also experimented with commenting out or changing debug settings but such activities give no improvements as well.

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

2 seconds is very big response time for the application without any functionality and running on the local machine with plenty of resources. We have experience that quite complex Yii applications respond in less than 0.5s and that is fine, but 2 seconds is unacceptable time.

I am using XAMP, PHP 7+, Yii 2.0.14, there is issue filed https://github.com/yiisoft/yii2/issues/15776 that 2.0.14 specifically may be slower but issue is not confirmed, as I understand.

I downgraded the same project to Yii 2.0.5 and tried it under XAMPP with PHP 5.6.23 and the performance is excellent. All the index.php request is completed under 100ms (in Yii 2.0.14 / PHP 7+ it took more than 2s).

Another finding - Yii 2.0.13 basic app works fast under XAMPP PHP 5.6, but this same app return page after more than 2s under XAMPP PHP 7.2. So, possibly the performance problems are not due to Yii2.

How to proceed? What other profiling to do? What other settings to change?

1条回答
Root(大扎)
2楼-- · 2019-08-24 12:32

I was investigating the same issue and in my case it was related to xDebug.

I'm using Windows 10 for developing, php 7.1.17 and Yii 2.0.15.1 and tested with the yii basic application.

I also tried yii 2.0.14 / 2.0.13 / 2.0.6 / 2.0.5 and there was always a TTFB of +1100ms.

After disabling xDebug in the php.ini the TTFB dropped to 250ms, which is excellent and feels perfectly fine.

Maybe this issue is related to xDebug and happens only while developing, on the production server it should be fine!

查看更多
登录 后发表回答