PHP is slow to respond when database operations are involved (TTFB time is long)

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.