Database Persistent PHP connection (first knowledge)

Source: Internet
Author: User

The general script runs to the end to release the database connection. Persistent connection is the end of the script does not close the connection, PHP will check if there is already a persistent connection, if it exists, directly use this connection, if not exist, establish a new connection.


Same: Same configuration file (user name, password, connection to the same host).



In the current popular PHP architecture for the Apache module, for a multi-process server, the typical feature is that there is a parent process and a set of sub-processes coordinated run, where the actual generation of the Web page is a child process. Whenever a client requests a parent process, the request is passed to a child process that is not occupied. After a persistent connection is enabled, all subsequent pages of the requested SQL Service can reuse the established connection.


Persistent connections are more efficient when Web server creates a connection to database server that is expensive. It's obvious.


But the problem comes, if the database connection only allows 16, so that when the 17th connection to the time can not be successfully established. This process will always try to connect, then one thread will not be able to connect, this time the script has a connection cannot be closed error, wireless loop and so on.



This digest from http://php.net/manual/zh/features.persistent-connections.php

Database Persistent PHP connection (first knowledge)

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.