Long connections for PHP and MySQL

Source: Internet
Author: User
Tags php and mysql php mysql
About PHP MySQL long connection, connection pool some of the way to explore PHP connection to MySQL, with more is the MySQL extension, mysqli extension, Pdo_mysql Extension, is officially provided. PHP operation mechanism is that the page will release all the resources in the PHP process, if there are multiple concurrent access to the local test page depending on PHP and the Web server, will open the appropriate thread or process to process the request, The result will be released when the request is finished. That is, PHP is unable to transfer some data from the page to the page from the language level, but mysql_pconnect with the ATTR in PDO, setting the array (Pdo::attr_persistent = True) as follows to enable long connections. $conn = new PDO ($DSN, Db_user, Db_password,    array (pdo::attr_persistent = true)); the effect of long connection I think is in the case of high load, by multiplexing the long connection, The time to establish a database connection for each page was reduced, while this built MySQL connection time on my machine in the case of database Connnections < 10, MySQL PDO was established with a connection of 0.003MS, Mysqli established connection time for 0.14MS when the database connection close to full, MySQL PDO is established connection times 0.13MS, mysqli build connection Time is 0.13MS

Long connections for PHP and MySQL

Related Article

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.