Pconnect of php

Source: Internet
Author: User
Tags pconnect


What is the difference between the two funconnect connect and PCONNECT functions of PHP during MYSQL connection? The answer to the general benchmark is: PCONNECT is a disruptive connection, and PHP will reuse existing resources to improve the performance.
But when I continue to ask questions, I can say that there are many fewer people who often see the following questions: When should I use CONNECT and when should I use PCONNECT? When is mysql_close used? Why is there a bunch of SLEEP processes on the DATABASE? Why is the resource id different every time when PCONNECT is used?
First, go back to the simplest solution, and pconnect will check whether there are existing resources. If yes, you can use the dynamic route. If no, you can create a new dynamic route. However, you can check the dynamic route, it refers to the information provided during this APACHE journey, rather than the information provided by this web server. A web server may have hundreds of APAHE itineraries (up to 2.0 in 150) that is to say, in most cases, there may be hundreds of PCONNECT-related data records (in fact, they will be less) therefore, using PCONNECT in the same way may produce different RESOURCE IDs because it may be performed on different routes.
PCONNECT does not close the connection after the query is completed, instead, it will wait for a certain period of time. This time can be set by wait_timeout on MYSQL, and mysql_close does not have a way to close the hosts opened by pconnect, only the information provided by connect is allowed. However, if there is no CLOSE, it will also be dropped by the DB after the TIMEOUT time.
PCONNECT must be used with caution. In poor CODE, a large number of DATABASE connections will be reserved. The maximum value can be used to calculate the APACHE Route number of each SERVER. * The number of all web servewr does not need to be reminded. Each region consumes the cpu time and MEMORY of the database.
When using web code, there are two reasons for using the statement: first, what information should we capture from the DATABASE? Second, what information should be sent to the USER end (in fact, this is not only used for the WEB) DATABASE is very slow and can capture the required information at a time, not twice.

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.