views:

967

answers:

2

Hello everyone,

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.

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

thanks in advance, George

+1  A: 

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

32,767 is the max limit per database.

I would do it as follows:

SELECT
     COUNT(*)
FROM
     master.dbo.syslockinfo
WHERE 
     DB_NAME(rsc_dbid) = 'your_database_name'
Nissan Fan
Is my method of finding active connection number correct? If yes, do you mean the number I find should never exceed 32,767?
George2
I just want to make sure the connection number I am finding is the same thing as you said. :-)
George2
From your referred MSDN document, my most confusion is -- what is the differences between "Connections per client" and "User connections"?
George2
+2  A: 

It is a per-instance, not per database, configuration. You can check the current value in sys.configurations and change it with sp_configure. The relevant option is 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.

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

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 threads option.

Remus Rusanu
So excellent, let me study for a while. :-)
George2
Me too :) I always took for granted that 32k+ user slots would never be a concern, but these particulars are really good details.
Nissan Fan
Thanks Nissan, I studied the following link, http://msdn.microsoft.com/en-us/library/ms143432.aspx, my most confusion is -- what is the differences between "Connections per client" and "User connections"?
George2
1. I am confused about your comments -- "connections actively executing something, sys.dm_exec_requests". What do you mean "something" here? Do you mean "something" is "sys.dm_exec_requests"? 2. I think the number of connection should be the same as that of requests if MARS is not used. Is that correct understanding? Any comments?
George2
'something' means a SQL batch sent to the server (ie. a 'request'). The connections are always present as long as the client keeps the conneciton open. A request is only present from the moment the batch arrived at the server until the result is sent back to the client. Requests are visible in sys.dm_exec_requests.
Remus Rusanu
Thanks for comments Remus, I am using sp_who2 or sys.dm_exec_connections to find active connections numbers, is that the correct method to count number of active connections?
George2
define 'active connection'. sp_who will show system tasks (lazuy writer, ghost writer, resource monitor etc) that don't have a conneciton. sys.dm_exec_connections will show connections that don't execute anything. Also sys.dm_exec_connections show non T-SQL conenctions like Mirroring ones, you must filter out base don protocol_type.
Remus Rusanu
Thanks Nissan, I studied the following link, http://msdn.microsoft.com/en-us/library/ms143432.aspx my most confusion is -- what is the differences between "Connections per client" and "User connections"?
George2
And if you think my two methods to monitor SQL Server active connections are not perfect, I want to learn your perfect method to monitor SQL Server active connections. Thanks. :-)
George2
I read again the document of sys.dm_exec_connections , and seems it does not say it will show idle connections along with active connections (i.e. no connection status column returned), how do you know "sys.dm_exec_connections will show connections that don't execute anything"? http://msdn.microsoft.com/en-us/library/ms181509.aspx
George2
You better read up here: http://msdn.microsoft.com/en-us/library/ms189267.aspx
Remus Rusanu