Questions about continuous requests and database connection
Source: Internet
Author: User
For continuous requests, there is a button to connect to the database. the user will connect to the database every time he clicks .. In this way, MYSQL is under pressure due to the excessive number of connections. I plan to optimize it on the front end. there is a time interval (for example, 3 seconds) before and after each click, but this does not seem to solve the fundamental problem, can I change to persistent connections ?, Take it for granted? In this way, the database connection problem may occur due to constant requests.
Suppose there is a button, the user will connect to the database every time they click ..
This will cause MYSQL pressure due to excessive connections
I plan to optimize the front-end. there is a time interval (3 seconds) before and after each user click)
However, this does not seem to solve the fundamental problem. can I change to a persistent connection?
------ Solution --------------------
Take it for granted?
This will cause MYSQL pressure due to excessive connections
Imagine if there is only one user, he has ordered 10 consecutive times. You feel a lot of pressure
So there are 100 users, and each user clicks. So do you feel a lot of pressure or not?
------ Solution --------------------
Specific Analysis: remember to close the connection when there is a connection.
Set the connection timeout value. Or you can directly set the maximum number of connections on the server. Avoid using mysql as a machine.
------ Solution --------------------
So you should set a limit on the front-end. it takes a few minutes to start or stop. Php releases the link immediately after obtaining data, or caches data. what is the second kill for a group of people to click the button?
Discussion
Reference:
Reference: Well, let's see if there is pressure. if it doesn't work well, you are under great pressure. Does the database mean it's calm? Are you worried?
It should be 100 users, with each user under 10
If the user is crazy, it will not work if the number of connections reaches 800, and the maximum number of connections is 5000 (800 is not all the user operations described above, and some other operations, lock tables ...)
Interactive_timeout and wait_timeout are both set to 20 seconds (change to 5 seconds is too short ......
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