连接池与什么相关?

发布于 2024-07-20 00:45:29 字数 242 浏览 5 评论 0原文

我正在阅读有关 .net 中的连接池的内容,但我不确定我是否理解正确。 他们说关闭的连接将返回到池中,以便以后可以重用。 但池与什么相关呢? 它是数据库还是只是应用程序环境(执行它的计算机)? 如果是后者,那么如果您有两个用户在两台不同的计算机上打开他们的应用程序并相继请求相同的连接,那么连接池不会产生任何影响,对吗?

编辑:当然,我知道如果同一个应用程序再次打开同一个连接,将会产生影响,但是同一个应用程序的两个不同实例又如何呢?

I'm reading about connection pooling in .net and i'm not sure if i'm getting it right. They say that a closed connection is returned to the pool so that it can be reused later. But what is the pool associated with? Is it a database or just the application environment (computer it is executed on)? If it's the latter, then if you have two users opening their applications at two different computers and requesting the same connection one after another, the connection pooling doesn't make the difference, am i right?

Edit: of course i know it will make a difference if the same app opens the same connection again, but what about two different instances of the same app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

她说她爱他 2024-07-27 00:45:29

连接池仅限于客户端 PC,并与连接字符串和身份验证详细信息相关联。

因此,如果连接关闭并返回到池中,只有连接字符串和身份验证详细信息完全匹配时,才会重用该连接。

Connection pools are limited to the client PC and are associated with the connection string and the authentication details.

So if a connection closes and returns to the pool it will only be reused if the connection string and authentication details match exactly.

无人问我粥可暖 2024-07-27 00:45:29

连接池只是客户端的一个集合,当您第一次尝试打开与数据库的连接时,它会充满连接。 如果您完成了连接对象的使用,则不会将其释放,而是返回到可用连接的集合。

通过这种方式,您可以获得性能提升,因为打开和关闭数据库连接可能非常昂贵(考虑建立连接所需的网络流量)。

这是关于该主题的一个很好的启动教程:

http://www.eggheadcafe.com/tutorials/aspnet/df2b05d8-93ea-49e1-aeaa-d116a4d6ac3b/adonet-connection-poolin.aspx

Connection pool is just a collection on the client side, that gets filled with connections when you first try to open a connection to database. If you finished working with the connection object, it is not disposed, but returned to the collection of available connections.

This way you get a performance boost, as opening and closing database connections can be very expensive (think about network traffic that is needed to establish a connection).

This is a good startup tutorial on the topic:

http://www.eggheadcafe.com/tutorials/aspnet/df2b05d8-93ea-49e1-aeaa-d116a4d6ac3b/adonet-connection-poolin.aspx

楠木可依 2024-07-27 00:45:29

ConnectionPoolCollection 实际上是一个保存 ConnectionPool 对象的单例对象。

您可以通过反射 DbConnection 上用于清除单个池或清除所有池的静态函数来对此进行测试。

ClearAllPools - 清除 SQL Server 中 DbConnection 的所有池。

由于该对象是单例,因此它不能跨进程边界工作。 您最终将得到每个进程一个池。

有一些 ADO.NET 提供程序可以通过使用 COM 对象来保存实例引用来跨应用程序进程进行池化,但大多数提供程序并不这样做。

The ConnectionPoolCollection is actually a singleton object that holds ConnectionPool objects.

You can test this by reflectoring the static functions on the DbConnection for clearing a single pool or clearing all pools.

ClearAllPools - Clear all the pools from a DbConnection in SQL Server.

Since the object is a singleton it does not work across process boundaries. You will end up with a pool per process.

There are some ADO.NET providers that can pool across application processes through the use of a COM object to hold the instance refs, but most do not do this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文