How Can I disable mysql_pconnect persistent connection?

Source: Internet
Author: User
How Can I disable mysql_pconnect persistent connection? When I connect to the database in php, because it is slow to collect data, I use mysql_connect to connect to the database and test everything on the local computer. but on the VM, I am prompted that the server has no response, later, I switched to mysql_pconnect for persistent connections. However, I recently found that how can I disable mysql_pconnect for persistent connections?
When I connect to the database in php, because it is slow to collect data, I use mysql_connect to connect to the database and test everything on the local computer. but on the VM, I am prompted that the server has no response, later, I switched to mysql_pconnect for persistent connections, but recently I found that the page is always unavailable. I suspect that mysql_pconnect is the persistent connection that consumes resources?
As I checked in the document, mysql_pconnect cannot be closed using mysql_close?

In this case, is it dangerous to use mysql_pconnect? Once this function is called, the connection cannot be closed at all? Until the resources are consumed?

Thank you !! Share:
------ Solution --------------------
Php connects to mysql in two steps
Step 1: establish a physical connection between the TCP/IP channel from php to the mysql server
Step 2: log on to the mysql server and establish a logical channel to the database

Whether it is a persistent connection or a short connection, the php program will close the logical channel.
Transient connections close the physical connection at the same time.
Persistent connections save the physical channels for reuse.

When a persistent connection is initiated, the system first checks whether there are idle physical channels. If yes, the system uses them. Otherwise, a physical channel is created.
It takes some time for the physical channel to be idle from the beginning to be used again (it must be communicated with mysql before it can be determined, and this work must be completed when mysql is relatively idle ). Therefore, when mysql and php are on the same machine, because there is no real network communication response extremely fast, there is almost no time to make the idle physical channel in an alternative state. As a result, a large amount of resources are occupied and the system crashes.
When mysql and php are not on the same machine, there is no (or very few) such situation.

------ Solution --------------------
Read this article to learn more about mysql_pconnect.
Http://www.cnblogs.com/funlake/archive/2011/09/08/2171822.html

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.