PHP's MySQL performance optimization

Source: Internet
Author: User

PHP in connection with the MySQL database when we can use a temporary connection, of course, we can also use permanent connection, the use of permanent connection because of the cost of a connection, so the time is greatly reduced, but we only use a permanent connection when we must pay attention to some of the problems?

Permanent connection in the case of a database crash or otherwise, a permanent connection does not know that the database has been shut down, and then to connect to the database will be wrong, the solution is to write a method to check the state of the database regularly, if the error on the new connection.

The permanent connection between PHP and the MySQL database is to create some threads, then find an idle connection in the thread pool every time you connect, but the Apache server only supports a certain number of threads, and when the server's traffic is particularly high, The connection threads of the database may exceed the number of Apache server support, which may cause the server to crash, so we need to modify the maximum number of threads in the configuration file of the Apache server to keep the server stable.

When multiple users use a permanent connection at the same time, may be back to the data error, or read dirty data, and other circumstances, this is our often to the issue of the doctrine!

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.