Questions about the number of connections and connection times for MySQL
Source: Internet
Author: User
Questions about the number of connections and connection times for MySQL
1, access to the page a.php, database connection, SLEEP5 seconds, no other action
2, the use of the way is not a persistent connection
3. Connection timeout set to 10 seconds
Should the connection be closed after 10 seconds without actively shutting down the connection? But it automatically shuts down after 5 seconds.
Why is that?
1, when everyone is generally connected to the database, only when the operation of the database?
My connection database is written in the configuration file, basically a page will be used in the database, all in the head introduced, but access to the page does not necessarily need database operations.
In other words, as long as someone accesses the file will be a database connection (even if you do not have to do database operations), is this a bad way?
MySQL Maximum number of connections is 5000, if there is 5000 + people access will be a problem?
2, in addition to ask a question, resulting in a static page to visit a slow reason some? Is it related to the number of request servers, JS, pictures?
Thank you
------Solution--------------------
1, the connection timeout is set to 10 seconds, that is, when 10 seconds is not connected to the database will no longer attempt to connect
2. Connect the database only when needed
3, MySQL maximum number of connections is 5000, indicating that 5000+ a connection request from the client will make an error
However, this situation does not occur because the Web server can allow a limited number of concurrent connections. A medium-sized website with 10 certificates is available.
4. Causes a slow access to a static page: too many files in a single directory (>1000)
------Solution--------------------
Because after 5 seconds a.php execution is over, all resources including MySQL connection will be released.
Database connections only 5000 + people access at the same time will be problematic.
------Solution--------------------
should be the SQL operation is closed after the link, if the SQL operation more than 10 seconds, the MySQL link will be automatically closed!
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