思考数据库连接池大小的决定 [英] Thinking behind decision of database connection pool size
问题描述
我正在开发基于java的应用程序,即xwiki。 Insie hibernate.cfg.xml我可以看到参数的值connection.pool_size和
statement_cache.siz为2(每个)。我的应用程序将在最大负载100个用户的时间点。现在我的问题是什么应该
是理想的连接池大小为此。对我来说大小2看起来很少。如果100个用户每次连接98个用户不得不等待释放
连接?在我的情况下,我应该保持连接池大小为100吗?
i am working on opensource java based application i.e xwiki. Insie hibernate.cfg.xml i can see value of parametrs connection.pool_size and statement_cache.siz as 2(for each). My application will be having maximum load of 100 users at point of time. Now my question is what should be ideal connection pool size for this. To me size 2 looks very less. If 100 users connect at a time 98 users have to wait for grtting the connection released? Should i keep the connection pool size as 100 in my case?
我使用microsoft sql server。
i am using microsoft sql server.
除此之外,还有最大连接池大小的限制。
Apart from this is there a limit on max connection pool size. Does it depend on webserver(tomcat in my case) or datastore vendor(ms sql server)?
推荐答案
如果一个典型的请求花费了多少,那么它是否依赖于webserver(我的情况下是tomcat) 50%的时间进行计算,50%的数据库连接,您可能只需要50个连接在您的池。当然,你的应用程序应该尽早释放数据库连接。
If a typical request spends 50% of its time doing calculations and 50% on database connectivity you might only need 50 connections in your pool. Of course your application should release the db connection as early as possible.
一般情况下,持有一个数据库连接并不昂贵(创建一个新数据库相当昂贵) 。
In general holding a connection is not expensive for a database (while creating a new one is quite expensive). It should be no problem to keep the size high enough.
您可以设置
- 最大池大小为100
- 首选池大小为50
- 以及池连接的空闲超时时间为5分钟。
我不熟悉microsoft sql server,但我认为它的 max pool limit is 100
I am not familiar with microsoft sql server but I think its max pool limit is 100
Tomcat会正常使用此号码的池大小。
Tomcat will be fine with this number of pool size.
这篇关于思考数据库连接池大小的决定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!