C# SQL Server 连接数有限制吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1499718/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:11:33  来源:igfitidea点击:

any limit of SQL Server connection count?

c#.netsql-serversql-server-2008ado.net

提问by George2

I am using SQL Server 2008 Enterprise + C# + ADO.Net + .Net 3.5. I am using sp_who2 or sys.dm_exec_connections to find active connections numbers (let me know if my method to find active connection numbers are wrong). For some heavy database consumer application, I can find even active connection count > 1000.

我使用的是 SQL Server 2008 Enterprise + C# + ADO.Net + .Net 3.5。我正在使用 sp_who2 或 sys.dm_exec_connections 来查找活动连接号(如果我查找活动连接号的方法有误,请告诉我)。对于一些繁重的数据库消费者应用程序,我什至可以发现活动连接数 > 1000。

I am wondering whether there are any upper bound limitations of active connection numbers of SQL Server?

我想知道SQL Server的活动连接数是否有上限限制?

thanks in advance, George

提前致谢,乔治

采纳答案by Remus Rusanu

It is a per-instance, not per database, configuration. You can check the current value in sys.configurationsand change it with sp_configure. The relevant option is user connections:

它是针对每个实例的配置,而不是针对每个数据库的配置。您可以检查当前值sys.configurations并使用 更改它sp_configure。相关选项是user connections

Use the user connections option to specify the maximum number of simultaneous user connections allowed on Microsoft SQL Server. The actual number of user connections allowed also depends on the version of SQL Server you are using and the limits of your application or applications and hardware. SQL Server allows a maximum of 32,767 user connections.

使用用户连接选项指定 Microsoft SQL Server 上允许的最大并发用户连接数。允许的实际用户连接数还取决于您使用的 SQL Server 版本以及应用程序或应用程序和硬件的限制。SQL Server 最多允许 32,767 个用户连接。

1000 of connections is not an exceedingly high number. On high end systems the server can listen on multiple ports affinitized to NUMAnodes and have hundreds and thousands of clients connected to each node.

1000 个连接并不是一个非常高的数字。在高端系统上,服务器可以侦听关联到NUMA节点的多个端口并且有成百上千的客户端连接到每个节点。

Note that the number of connections is different from the number of requests, ie. connections actively executing something, sys.dm_exec_requests. Each Request requires one or more workers and the number of workers is configured with the max worker threadsoption.

请注意,连接数与请求数不同,即。主动执行某事的连接,sys.dm_exec_requests。每个请求都需要一个或多个工作人员,工作人员的数量由该max worker threads选项配置。

回答by Keith Adler

http://msdn.microsoft.com/en-us/library/ms143432.aspx

http://msdn.microsoft.com/en-us/library/ms143432.aspx

32,767 is the max limit per database.

32,767 是每个数据库的最大限制。

I would do it as follows:

我会这样做:

SELECT
     COUNT(*)
FROM
     master.dbo.syslockinfo
WHERE 
     DB_NAME(rsc_dbid) = 'your_database_name'