What scenario is the database long link in PHP applied to?

Source: Internet
Author: User
What scenario is the database long link in PHP applied to? Like what mysql_pconnect

Reply content:

What scenario is the database long link in PHP applied to? Like whatmysql_pconnect

Are you asking for a permanent (persistent) link to the database?

The official answer is:

The answer is simple – efficiency .

Permanent connections are more efficient when clients connect to your SQL server with very frequent requests. The criteria for frequent connection requests depend on many factors. For example, the type of database, whether the database service and WEB services are on the same server, how SQL server loads the load, and so on. But at least we know that a permanent connection increases efficiency significantly when connection requests are frequent . It allows each sub-process to do only one connection operation in its life cycle, rather than making a connection request to the SQL server each time a page is processed. This means that each sub-procedure establishes a separate, permanent connection to the server.

For example, if you have 20 different sub-procedures that run a script that establishes a permanent connection to the SQL Server, you actually establish 20 different permanent connections to the SQL Server, each of which occupies one.

Note that if the number of child processes that are permanently connected exceeds the number of database connections you set, the system will have some drawbacks. If your database has a limit of 16 simultaneous connections, and in the case of a busy session, there are 17 threads trying to connect, then one of the threads will not be able to connect. If at this time, there is an error in your script that makes the connection impossible to close (for example, an infinite loop), then 16 connections to that database will be affected quickly.

Note : This link is not permanent and does not provide any reply function.

is the chat room counted?

  • 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.