1
votes

While rendering the view in Yii2, I noticed the render time is a bit too long. And here is a part of log:

03:57:57.435 info yii\db\Command::query SELECT * FROM user_profile WHERE userid IN (16, 15, 12)

03:57:57.501 trace yii\base\View::renderFile

please notice the time between in the two steps, almost takes more than 80ms. The render view is simple, just a gridview widget with my own code. The less page size is, the less render time it costs. When the column is about 15 items it almost takes 250ms to render the view. Besides, the sql queries takes 2ms in total.

'columns' => [
            [
                'header' => 'Article title',
                'attribute' => 'article_title',
                'format' => 'html',
                'value' => function ($dataProvider) {
                    /**
                     * bunch of code
                    */
                    return $info;
                },
            ],
        ],

So is that the code file causes this? Should I rebuild my code?

1
what does the network panel shows if it is not related to your db? are you using any AppAssets bundle for you application. - Muhammad Omer Aslam
Just the default appasset, and the network shows the page Waiting (TTFB) 261.22 ms - Yuzuha
I experience the same behaviour. As soon as gridview gets involved, renderFile will introduce wait times of up to 1000 ms (in my case) on a beefy server. - SebiF
@SebiF I currently reduce the pagesize as the temporary solution, I guess I have to rewrite a gridview which suits my case. - Yuzuha

1 Answers

0
votes

I also had this problem, TTFBs of 250ms to 1sec. By modifying Apache to use fpm setup, you should be able to reduce load times down to 35ms.

https://www.cloudways.com/blog/php-fpm-on-cloud/amp/