Q:

Yii2 performance: render view takes too long

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?

A:

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/

