Home  >  Article  >  PHP Framework  >  What is the reason why yii2 responds too slowly?

What is the reason why yii2 responds too slowly?

藏色散人
藏色散人Original
2020-07-20 11:05:593345browse

The reason for the slow response of yii2 is that when php5.3 or above encounters localhost, it will consider whether it is ipv4 or ipv6, which will lead to a long response time. The solution is to change "localhost" Just "127.0.0.1".

What is the reason why yii2 responds too slowly?

The reason why yii2 feels slow [2.0 version]

'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
    'username' => 'root',
    'password' => '123456',
    'charset' => 'utf8',
]

There is no problem with the above code itself

But when php5.3 or above encounters localhost, it will consider whether it is ipv4 or ipv6, so the response time will be too long. If you check the time it takes for the server to process PHP, you will find that the time it takes to process PHP is very short, and the time it takes to wait for processing is very long. It only happens under Windows systems.

Solution:

Change localhost to 127.0.0.1 so that php will immediately know that it is ipv4

Then you will find that it is much faster~~~~

Recommendation: "yii tutorial

The above is the detailed content of What is the reason why yii2 responds too slowly?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn