• 关于ado.net连接池的一些分享(原文出自:http://www.cnblogs.com/rickie/archive/2004/10/02/48546.aspx)


    建立池连接可以显著提高应用程序的性能和可缩放性。SQL Server .NET Framework 数据提供程序自动为 ADO.NET 客户端应用程序提供连接池(MSDN)。

    Opening a database connection is a resource intensive and time consuming operation. Connection pooling increases the performance of Web/windows applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.

    Connection pooling behavior is controlled by the connection string parameters. Please look into MSDN documents in the reference link if you want to know further information.

     

    前面是关于连接池知识的一些基本介绍,下面的内容是重点,也是个人见解。因为没有这方面的文档资料参考或者佐证,所以请各位仔细思考和讨论(我不想误导大家)。

    下面分2种情况进行讨论。

    1Client端的windows form application通过ADO.Net直接访问后台Database


    我认为在这种情况下,每一个Client端和Database之间都存在一个连接池。通过设置ConnectiongStringMax Pool SizeMin Pool Size属性来验证。

    Max Pool Size = 5, Min Pool Size = 3, 通过SQL ServerSP_WHO2可以检测导如下结果:

    启动1Client端的Windows form applicationapplicationSQL Server之间存在3connection

    启动2Client端的Windows form applicationapplicationSQL Server之间存在6connection

    启动3Client端的Windows form applicationapplicationSQL Server之间存在9connection

     

    由此可见,每一个Client端和SQL Server之间都存在一个连接池,否则9connection已经超出了Max Pool Size的设定。

     

    2Client端的application不直接通过ADO.Net来访问后台Database,而是通过IIS Server来同后台Database Server打交道。

    至少有如下2种情况:

    1Client通过IE访问部署在IIS中的web applicationweb application中的Data Access Class进一步访问后台Database Server.

    2Client端的windows form application访问部署在IIS中的Remote ObjectRemote Object进一步访问后台Database Server.



    下面进行同样的测试:通过设置ConnectiongStringMax Pool SizeMin Pool Size属性来验证。

    Max Pool Size = 5, Min Pool Size = 3, 通过SQL ServerSP_WHO2可以检测导如下结果:

    启动1Client端的Web form applicationapplicationSQL Server之间存在3connection

    启动2Client端的Web form applicationapplicationSQL Server之间存在3connection

    启动3Client端的Web form applicationapplicationSQL Server之间存在3connection

     

    调用由IIS承载的Remote Object,结果类似。只是在未启动Client端之前,发现在Remote ObjectDatabase Server之间已经存在一个connection

     

    由此可见,对同一个application而言,IIS ServerDatabase Server之间只有存在一个连接池,与Client端的多少没有关系。

     

    3,连接池小节

    根据上面的测试结果,显然第二种情况更有利于减少无用的连接数量,提高Database Server的性能。关于.Net Remoting技术及其性能问题,可以参考如下的Reference连接,这里就不讨论了。

    另外,本文是个人关于连接池的一些见解,如果观点有不正确之处,希望不要误导各位。欢迎各位在此发表意见。同意的说赞同,不同意的请提出您的看法。谢谢。

     

    Reference Links:

    (1) MSDN, ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconconnectionpoolingforsqlservernetdataprovider.htm

    (2) Microsoft .NET Remoting:技术概述http://www.microsoft.com/china/MSDN/library/NetFramework/default.mspx

    (3) 性能比较:.NET Remoting  ASP.NET Web 服务http://www.microsoft.com/china/msdn/archives/library/dnbda/html/bdadotnetarch14.asp

    建立池连接可以显著提高应用程序的性能和可缩放性。SQL Server .NET Framework 数据提供程序自动为 ADO.NET 客户端应用程序提供连接池(MSDN)。

    Opening a database connection is a resource intensive and time consuming operation. Connection pooling increases the performance of Web/windows applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.

    Connection pooling behavior is controlled by the connection string parameters. Please look into MSDN documents in the reference link if you want to know further information.

     

    前面是关于连接池知识的一些基本介绍,下面的内容是重点,也是个人见解。因为没有这方面的文档资料参考或者佐证,所以请各位仔细思考和讨论(我不想误导大家)。

    下面分2种情况进行讨论。

    1Client端的windows form application通过ADO.Net直接访问后台Database


    我认为在这种情况下,每一个Client端和Database之间都存在一个连接池。通过设置ConnectiongStringMax Pool SizeMin Pool Size属性来验证。

    Max Pool Size = 5, Min Pool Size = 3, 通过SQL ServerSP_WHO2可以检测导如下结果:

    启动1Client端的Windows form applicationapplicationSQL Server之间存在3connection

    启动2Client端的Windows form applicationapplicationSQL Server之间存在6connection

    启动3Client端的Windows form applicationapplicationSQL Server之间存在9connection

     

    由此可见,每一个Client端和SQL Server之间都存在一个连接池,否则9connection已经超出了Max Pool Size的设定。

     

    2Client端的application不直接通过ADO.Net来访问后台Database,而是通过IIS Server来同后台Database Server打交道。

    至少有如下2种情况:

    1Client通过IE访问部署在IIS中的web applicationweb application中的Data Access Class进一步访问后台Database Server.

    2Client端的windows form application访问部署在IIS中的Remote ObjectRemote Object进一步访问后台Database Server.



    下面进行同样的测试:通过设置ConnectiongStringMax Pool SizeMin Pool Size属性来验证。

    Max Pool Size = 5, Min Pool Size = 3, 通过SQL ServerSP_WHO2可以检测导如下结果:

    启动1Client端的Web form applicationapplicationSQL Server之间存在3connection

    启动2Client端的Web form applicationapplicationSQL Server之间存在3connection

    启动3Client端的Web form applicationapplicationSQL Server之间存在3connection

     

    调用由IIS承载的Remote Object,结果类似。只是在未启动Client端之前,发现在Remote ObjectDatabase Server之间已经存在一个connection

     

    由此可见,对同一个application而言,IIS ServerDatabase Server之间只有存在一个连接池,与Client端的多少没有关系。

     

    3,连接池小节

    根据上面的测试结果,显然第二种情况更有利于减少无用的连接数量,提高Database Server的性能。关于.Net Remoting技术及其性能问题,可以参考如下的Reference连接,这里就不讨论了。

    另外,本文是个人关于连接池的一些见解,如果观点有不正确之处,希望不要误导各位。欢迎各位在此发表意见。同意的说赞同,不同意的请提出您的看法。谢谢。

     

    Reference Links:

    (1) MSDN, ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconconnectionpoolingforsqlservernetdataprovider.htm

    (2) Microsoft .NET Remoting:技术概述http://www.microsoft.com/china/MSDN/library/NetFramework/default.mspx

    (3) 性能比较:.NET Remoting  ASP.NET Web 服务http://www.microsoft.com/china/msdn/archives/library/dnbda/html/bdadotnetarch14.asp

  • 相关阅读:
    [问题2014A13] 解答
    [问题2014A12] 解答
    [问题2014A13] 复旦高等代数 I(14级)每周一题(第十五教学周)
    [问题2014A10] 解答
    php使用amqplib方式使用rabbitmq
    Ubuntu 16.04 源码编译安装PHP7+swoole
    Ubuntu apt-get更换阿里云源
    微信企业号网页授权
    nginx转发swoole以及nginx负载
    PHP 命名空间
  • 原文地址:https://www.cnblogs.com/xienb/p/2831593.html
Copyright © 2020-2023  润新知