MySQL 的最大并发连接数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14901508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maximum concurrent connections to MySQL
提问by user2075703
I want to set up a MySQL database for a social networking website for my college.
我想为我的大学建立一个社交网站的 MySQL 数据库。
My app can have at most 10,000 users. What is the maximum number of concurrent MySQL connections possible?
我的应用最多可以有 10,000 个用户。最大并发 MySQL 连接数是多少?
回答by Marc B
As per the MySQL docs: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections
根据 MySQL 文档:http: //dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections
maximum range: 4,294,967,295 (e.g. 2**32 - 1)
You'd probably run out of memory, file handles, and network sockets, on your server long before you got anywhere close to that limit.
在您接近该限制之前很久,您的服务器上的内存、文件句柄和网络套接字可能已经用完。
回答by crush
You might have 10,000 users total, but that's not the same as concurrent users. In this context, concurrent scripts being run.
您可能总共有 10,000 个用户,但这与并发用户不同。在这种情况下,并发脚本正在运行。
For example, if your visitor visits index.php, and it makes a database query to get some user details, that request might live for 250ms. You can limit how long those MySQL connections live even further by opening and closing them only when you are querying, instead of leaving it open for the duration of the script.
例如,如果您的访问者访问 index.php,并进行数据库查询以获取一些用户详细信息,则该请求可能会持续 250 毫秒。您可以通过仅在查询时打开和关闭它们来限制这些 MySQL 连接的持续时间,而不是在脚本的持续时间内保持打开状态。
While it is hard to make any type of formula to predict how many connections would be open at a time, I'd venture the following:
虽然很难制定任何类型的公式来预测一次将打开多少个连接,但我会冒险进行以下操作:
You probably won't have more than 500 active users at any given time with a user base of 10,000 users. Of those 500 concurrent users, there will probably at mostbe 10-20 concurrent requests being made at a time.
在任何给定时间,如果用户群为 10,000,您的活跃用户可能不会超过 500。在这 500 个并发用户中,一次最多可能有 10-20 个并发请求。
That means, you are really only establishing about 10-20 concurrent requests.
这意味着,您实际上只建立了大约 10-20 个并发请求。
As others mentioned, you have nothing to worry about in that department.
正如其他人提到的,你在那个部门没有什么可担心的。