K
K
Khurshed Abdujalil2017-05-18 05:38:22
Yii
Khurshed Abdujalil, 2017-05-18 05:38:22

How to optimize Yii2?

Now the page loads in 0.73-0.88s, I debugged all requests + the template output time takes 0.2-0.3 seconds, which takes the rest of the time I can’t understand ... I calculated the execution time of all requests in Yii::getLogger()->getProfiling() takes 0.07 with

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
melnikov_m, 2017-05-18
@melnikov_m

in this case, if you are sure that the database queries are optimized, and the loading time still does not suit you, you can still try these options.
1) http-cache
2) Get away from using ActiveDataProvider (unless of course you have it on this page) towards ArrayDataProvider. At one time, this helped me a lot when it was necessary, at the request of the customer, to display 500 items in the list on one page. ActiveDataProvider ate a lot of memory and time to create objects and access its methods and properties. On arrays, everything began to fly three times faster ...

M
Maxim Fedorov, 2017-05-18
@qonand

The page loading speed depends not only on how fast the server processes the request, but also on many other factors, such as the size of the uploaded images, the size of styles and scripts, DNS record recognition, etc.
Here is a small overview of the points that affect page loading speed

M
mitaichik, 2017-05-18
@mitaichik

In addition to the previous answers: we must not forget about setting up the server - what is under your hood - nginx + php-fpm will not give such a delay, but apache + php_mod may well.
It is rather reckless to count the execution time only for queries to the database - php can also eat up quite a lot, not the fastest language.
Especially in the context of profiling, debugging - at the same time, Yii writes, collects and writes a huge amount of information to disk, if you disable YII_DEBUG, everything is possible and flies.
It can also slow down due to XDebug if it is enabled by default.
Well, it is unnecessary to forget that the speed of return is not a constant concept. And if on your virtual machine on the dev-machine it is 0.3, then on a normal server it may well be 0.1

A
Arman, 2017-05-18
@Arik

1.
https://github.com/yiisoft/yii2/blob/master/docs/g...
2. XHProf helps bottlenecks very well

P
Papa, 2017-05-18
Stifflera @PapaStifflera

Loading statics, for example. The higher the ping value, the longer it will take to load.

A
Alexander Aksentiev, 2017-05-18
@Sanasol

https://blackfire.io/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question