Delphi FireDac Firebird 4.0连接池化

huangapple go评论68阅读模式
英文:

Delphi FireDac Firebird 4.0 Connection Pooling

问题

我正在测试Firedac(Delphi 11 Update1)和Firebird 4.0(最新版本)用于一个REST API服务器项目。
我在Firebird文档和FireDac文档中找到了连接池技术作为一种可能性。
在我的测试应用程序中,我可以启用和禁用FireDac连接池,这有显著的差异,所以没问题。

但是Firebird 4.0的连接池启用和禁用没有任何区别。这个功能在Delphi、Firedac中是否有效,还是我漏掉了或不理解什么?

在Firebird.conf中:ExtConnPoolSize = 20,extConnPoolLifeTime = 10。

在Delphi端,我编写了一个小型测试代码,创建了一个“X”线程并运行它们,然后进行测量。在线程中:创建连接和一个查询,通过FDManager连接到数据库,运行查询,获取所有结果,并释放资源。我可以在Firebird 2.5上运行代码以进行对比,还可以在Firebird 4.0上运行。

配置:

  • Firebird 2.5.9 super 64位。
  • Firebird 4.0,super 64位。没有WireCompression,AuthServer = Srp,Srp256
  • 通过tcpip本地使用。

结果:

Firebird 2.5 
32位客户端
完整运行次数:100
线程数:1
峰值计数:0
平均时间:168
   最小:15
   最大:334

Firebird 4.0 
32位客户端
完整运行次数:100
线程数:1
峰值计数:0
平均时间:44
   最小:31
   最大:78

Firebird 2.5 
32位客户端
完整运行次数:100
线程数:4
峰值计数:3
平均时间:19
   最小:0
   最大:208

Firebird 4.0 在32位客户端上启用FBDatabasePool
完整运行次数:100
线程数:4
峰值计数:4
平均时间:21
   最小:15
   最大:47

Firebird 4.0 关闭FBDatabasePool
32位客户端
完整运行次数:100
线程数:4
峰值计数:6
平均时间:25
   最小:15
   最大:94
英文:

I'm testing Firedac (Delphi 11 Update1) and Firebird 4.0 (Latest) for a rest API server project.
I found the connection pooling technic in Firebird documentation as a possibility and also in FireDac documentation.
In my test application, I can enable and disable the FireDac Pooling, which has a significant difference, so it's OK.

But Firebird 4.0 Connection pool enabled and disabled no difference. Is this thing working in Delphi, Firedac or what do I miss or don't understand?

In Firebird.conf: ExtConnPoolSize = 20, and extConnPoolLifeTime = 10.

On the Delphi side, I wrote a mini-testing code, created an "X" thread and ran them, and measure them. In the thread: create Connection and one query, connect to the database via FDManager, run the query, fetch all, and free. I can run the code with Firebird 2.5 for control, and Firebird 4.0.

Configuration:

  • Firebird 2.5.9 super 64 bit.
  • Firebird 4.0, super 64 bit. no WireCompression, AuthServer = Srp, Srp256
  • Local usage via tcpip.

Results:

Firebird 2.5 
32Bit Client
Full Run count: 100
ThreadCount:1
PeakCount:0
Avarage Time: 168
   min: 15
   max: 334

Firebird 4.0 
32Bit Client
Full Run count: 100
ThreadCount:1
PeakCount:0
Avarage Time: 44
   min: 31
   max: 78

Firebird 2.5 
32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:3
Avarage Time: 19
   min: 0
   max: 208

Firebird 4.0 FBDatabasePool on 32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:4
Avarage Time: 21
   min: 15
   max: 47

Firebird 4.0 FBDatabasePool OFF
32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:6
Avarage Time: 25
   min: 15
   max: 94

 

答案1

得分: 3

在Firebird 4.0中引入的连接池是一个服务器端连接池,用于管理服务器本身创建的连接到其他数据库的情况,例如在PSQL execute statement ... on external 中的连接。它对客户端没有影响,比如你的Delphi应用程序(除非调用使用外部连接的PSQL代码的查询可能会略微快一些)。

换句话说,启用Firebird服务器端连接池后,你不会观察到任何性能改进,这在你的设置中是完全符合预期的。

如果你需要一个客户端连接池,你需要使用一个提供客户端连接池功能的合适库或组件,比如你示例中的FireDAC。

英文:

The connection pool introduced in Firebird 4.0 is a server-side connection pool used for connections the server itself creates to other databases. This concerns for example connections in PSQL execute statement ... on external. It has no effects client-side, like your Delphi application (other than that queries that invoke PSQL code which use external connections may run slightly faster).

In other words, that you don't observe any performance improvements when enabling the Firebird server-side connection pool is entirely expected for your setup.

If you need a client-side connection pool, you need to use an appropriate library or component which provides client-side connection pooling, like FireDAC in your example.

huangapple
  • 本文由 发表于 2023年6月22日 17:48:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定