连接重要吗?
我们有一个使用 NHibernate 连接到 SQL Server 上的数据库的应用程序。我们使用连接池和每个请求会话方法来通过 SQL Server 执行查询。 我们使用 SQL Server 活动监视器来监视连接计数,并注意到每当用户登录系统时就会涉及 25-30 个连接。 所以我要问的问题是:大量的 SQL Server 连接会导致性能问题吗?
We have an application that uses NHibernate to connect to our database on SQL Server.We use connection pooling and session per request approach to execute our queries over SQL Server.
We used SQL Server Activity Monitor to monitor connections count and noticed there was 25-30 connections involved whenever a user logged in to system.
So here's my question to ask : can large number of connections to SQL Server leads to performance issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次与 SQL Server 的连接都需要分配一定量的内存,因此在这方面需要考虑性能。
然而,在计划中,20-30 个连接是一个非常小的数字。
您是否已验证所有连接都属于您的应用程序?我问的原因是因为SQL Server本身将建立和维护一定数量的连接/会话作为服务器整体操作的一部分。
一些有用的 DMV 供您监控:
可以说,大于 51 的会话 ID 来自 SQL Server 外部,即用户会话。
进一步评论:
SQL Server 2005 最多可以支持 32,767 个连接。要检查您的容量,请执行:
如果正在使用连接池,则连接将保持打开状态并处于睡眠状态,直到需要处理请求为止。或者,当请求完成处理时,应用程序可能不会关闭连接。
我只能从 SQL Server 的角度发表评论,因为我不熟悉 NHibernate 的机制。
Each connection to SQL Server requires the allocation of certain amount of memory and so there is a performance consideration in this regard.
In the scheme of things however, 20-30 connections is a very small number.
Have you validated that all connections belong to your application? The reason I ask is because SQL Server itself will establish and maintain a certain number of connections/sessions as part of the servers overall operation.
Some usefull DMV's for you to monitor:
Session ID's above 51 are from outside of SQL Server so to speak, i.e. user sessions.
Further to comments:
SQL Server 2005 can support up to 32,767 connections. To check your capacity execute:
If connection pooling is being used then connections will remain open and in a sleep state until required for processing requests. Alternatively, perhaps the application is not closing connections when requests have finished processing.
I can only comment from a SQL Server perspective as I am not familiar with the mechanics of NHibernate.