When the database address is localhost, the Web site is opened very slowly ttfb a long time.
The local site needs to be parsed:
localhost 127.0.0.1
The Data book on the server if it is not true IP address proposed to replace the real IP address.
Description: The website is developed by PHP and most of the pages respond very slowly.
Local development responds quickly, but most of the response is slow after deployment to the production environment.
Through Google browsing debugging found that PHP page loading is slow, there are individual PHP request response time even more than 10 seconds, PHP request processing is not very complex, should not be so slow.
The main time spent on waiting (TTFB), some very slow page such as the 10.2-second page, waiting time unexpectedly reached 10 seconds.
Occasionally found that there are individual pages, in the case of non-landing quickly, the response is very slow after login, such a special view of the page, found that the login will be executed MySQL Select, do not log on directly display fixed content.
The lock is therefore slow to respond when the MYSQ operation is involved.
Wrote a simple MySQL select query, which was found to be slow through Web access, the time to discover by microtime () statistics execution time is dozens of milliseconds or milliseconds, but the waiting time is still the second level. This is obviously unscientific, and PHP has several orders of magnitude from the time it starts executing to the end and the Web response.
The MySQL operation is slow, but the time it takes for PHP to perform the MySQL operation is not slow.
Get this also have no way, can only go to search degrees Niang, the results also really searched, some people also appear the same situation in the degree Niang asked, unexpectedly still someone answered, suddenly feel good many ah.
By the respondents, localhost was used to connect to the database, but localhost was not configured in the hosts.
To see the hosts, a look, I go to ... There's no localhost.
Tim Plus
127.0.0.1 localhost
, the PHP Web Access speed in the build environment is immediately given force.