max_connections 的真正含义是什么?
我正在尝试为 MySQL 和共享主机上所需的资源设置理想的性能设置.
I'm trying to set the ideal performance setup for MySQL and resources needed on a shared hosting.
我的问题是,max_connections
到底是什么意思?
My question is, what does max_connections
really mean?
是对服务器发出的唯一并发请求数吗?因此,如果有两个用户,其中 1 个打开 1 个选项卡,另一个打开 4 个选项卡……并且同时按下所有选项卡重新加载,是否会与 MySQL 数据库建立 5 个连接?因此,如果我们将这种情况变成:10 个有 2 个标签的人和 31 个有一个标签的人同时按下刷新……我们的 max_connections
为 50,每个人都会被锁定吗?
Is it the number of unique concurrent requests made to the server?
So if there are two users, 1 with 1 tab open and the other with 4 tabs open... and both press all their tabs to reload at the same time, will there be 5 connections made to the MySQL DB? Consequently, if we bump this scenario to: 10 people with 2 tabs and 31 people with one tab all pressing refresh at the same time... with our max_connections
at 50, will everyone get locked out?
我问的原因是因为我想以较低的 max_connections
拍摄以节省内存资源,因为我一直看到该站点进入 CPU 节流模式
The reason I ask is because I want to shoot for low max_connections
to be conservative with memory resources since I consistently see the site going into cpu throttling mode
感谢您的帮助
推荐答案
是的,为每个页面打开了一个单独的连接.但是,假设您没有执行任何数据库密集型操作,一旦页面被提供给客户端,连接将是短暂的并自行关闭.
Yes, there is a separate connection opened for each page. However, assuming you're not doing anything database-intensive, the connection will be short-lived and close itself once the page has been served to the client.
如果确实超过了最大连接数,任何后续的连接尝试都将失败.
If you do exceed the maximum number of connections, any subsequent connection attempt will fail.
相关文章