当与Hibernate结合使用时,设置C3P0参数的值的最佳方法是什么? [英] Whats the best way to set the values of C3P0 parameters when it is in conjunction with Hibernate?
问题描述
首先请注意:问题是关于参数的值,而不是配置的方法。此外,我的问题是根据我的系统要求定制的。
First of all please note: question is about values of parameters not methods of configuration. Also, my question is customized to my system requirement.
我的系统将被20个发出请求的并发用户使用,我相信每个查询的最大响应时间为300秒。虽然我使用JMeter和应用程序工作,我怀疑idle_test_period的价值不应该超过超时值,但在大多数教程在线,他们不是。我想知道以下配置是否足以满足我的要求。并且idle_test_period的值是否应该超过超时?
My system is going to be used by 20 concurrent users who make requests, and I believe max time that each query would be responded would be 300 seconds. Although I used JMeter and the application worked, I suspect the value of idle_test_period should not be more than timeout value but in most tutorials online they are not. I am wondering if the following configuration is sufficient for my requirement. And whether the value of idle_test_period should be more than timeout or not?
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
Most websites configurations are the same such as : this and this
推荐答案
设置连接池大小是不是一件微不足道的事情。任何RDBMS将强加最大并发连接限制,我看到你已经选择了最大大小100连接。
Setting a connection pool size is not a trivial thing to do. Any RDBMS will impose a max concurrent connnection limit, and I see you have already chosen a max size of 100 connections.
通常,根据RDBMS引擎,操作系统和硬件,每个数据库节点(matser / slave)可能会获得100-300个最大并发连接。
Typically, based on the RDBMS engine, the OS and the hardware you might get 100-300 max concurrent connections per DB node (matser/slave).
所以,如果你计划加载平衡这个应用程序,或运行不同的应用程序都同意有限的数据库连接,那么事情变得非常复杂。
So if you plan to load balance this app, or run different apps all concurring for the limited db connections then things get really complicated.
我花了一些时间找到最好的连接池大小策略o这里是我的发现:
I dedicated some time to find the best connection pool sizing strategy o here are my findings:
因此,我建立了一个名为 FlexyPool 的开源项目允许您:
So, I build an open source project called FlexyPool that allows you to:
- 监控连接池行为(连接租用时间,连接获取时间,重试次数,
- 使您可以通过使用时间阈值策略中的池增量来找到正确的池大小。
希望它可以帮助您找到正确的池大小。
I hope it can help you finding the right pool size.
这篇关于当与Hibernate结合使用时,设置C3P0参数的值的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!