I
I
Isherath2019-10-01 04:25:13
Yii
Isherath, 2019-10-01 04:25:13

How to reduce memory consumption in Yii2?

I am writing a website on this framework and I am confused by the memory consumption of 8 meters per page with 15 requests to the database (it will not work to make one). At a time when a self-written framework that does everything I need, hawala a little more than 1.5 meters. My bike does not have active records like in Yii2. What do I need to disable in Yii2 so that I can upload the site to the host and not think that it will be cut down nah? logs and debugger are disabled.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Taroxx, 2019-10-03
@Isherath

Optimize queries in the database, enable the query cache in the config.
Optimization and only optimization.
My site can have over 1000 requests on a single page with 18mb memory consumption and 150ms load speed;
My settings are something like this:

'components' => [
     'db' => [
    'enableSchemaCache' => true,
          'schemaCacheDuration' => 3600,
          'schemaCache' => 'cache',
     ],

     'cache' => [
          'class' => 'yii\caching\MemCache'
     ],

]

Just enabling caching is not enough, you need to correctly scatter it in the views of everyone, so that not everything is cached in a row, this is dangerous for dynamic blocks. There is a lot of information on the Internet about this.
Minification and concatenation of all JS and CSS files also greatly reduces the load. yii2 has both built-in tools for this, as well as additional modules, such as rmrevin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question