简体   繁体   English

MySQL 的最大并发连接数

[英]Maximum concurrent connections to MySQL

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.我的应用最多可以有 10,000 个用户。 What is the maximum number of concurrent MySQL connections possible?最大并发 MySQL 连接数是多少?

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.在您接近该限制之前很久,您的服务器上的内存、文件句柄和网络套接字可能已经用完。

You might have 10,000 users total, but that's not the same as concurrent users.您可能总共有 10,000 个用户,但这与并发用户不同。 In this context, concurrent scripts being run.在这种情况下,并发脚本正在运行。

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.例如,如果您的访问者访问 index.php,并进行数据库查询以获取一些用户详细信息,则该请求可能会持续 250 毫秒。 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.您可以通过仅在查询时打开和关闭它们来限制这些 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.在任何给定时间,如果用户群为 10,000,您的活跃用户可能不会超过 500。 Of those 500 concurrent users, there will probably at most be 10-20 concurrent requests being made at a time.在这 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.正如其他人提到的,你在那个部门没有什么可担心的。

我可以向您保证,原始速度最终在于使用索引的非标准使用,以使用大表实现极快的速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM