需要使用Spring和Dbcp连接池进行数据库调优的输入

需要使用Spring和Dbcp连接池进行数据库调优的输入,spring,connection-pooling,apache-commons-dbcp,Spring,Connection Pooling,Apache Commons Dbcp,我在我的项目中使用Spring,并实例化数据源,如下所示 @Bean(destroyMethod="close") public DataSource restDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(env.getProperty("hibernate.connection.driver_class")

我在我的项目中使用Spring,并实例化数据源,如下所示

@Bean(destroyMethod="close")
    public DataSource restDataSource() {

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(env.getProperty("hibernate.connection.driver_class"));
        dataSource.setUrl(env.getProperty("hibernate.connection.url"));
        dataSource.setUsername(env.getProperty("hibernate.connection.username"));
        dataSource.setPassword(env.getProperty("hibernate.connection.password"));
        dataSource.setInitialSize(env.getRequiredProperty("hibernate.dbcp.initialSize", Integer.class));
        dataSource.setMaxActive(env.getRequiredProperty("hibernate.dbcp.maxActive", Integer.class));
        dataSource.setMaxIdle(env.getRequiredProperty("hibernate.dbcp.maxIdle", Integer.class));
        dataSource.setMinIdle(env.getRequiredProperty("hibernate.dbcp.minIdle", Integer.class));
        return dataSource;
    }
下面是我的属性文件

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.username=<>
hibernate.connection.password=<>
hibernate.connection.url=jdbc:oracle:thin:@<Host>:1521:<SID>
hibernate.show_sql=true

hibernate.cache.use_query_cache=true
cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate.cache.use_second_level_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
net.sf.ehcache.configurationResourceName=ehcache.xml
**hibernate.dbcp.initialSize=10
hibernate.dbcp.maxActive=100
hibernate.dbcp.maxIdle=30
hibernate.dbcp.minIdle=10**
hibernate.dialen=org.hibernate.dialen.oracle10galent
hibernate.connection.driver\u class=oracle.jdbc.driver.OracleDriver
hibernate.connection.username=
hibernate.connection.password=
hibernate.connection.url=jdbc:oracle:thin:@:1521:
hibernate.show_sql=true
hibernate.cache.use\u query\u cache=true
cache.provider\u class=org.hibernate.cache.EhCacheProvider
hibernate.cache.use_second_level_cache=true
hibernate.cache.region.factory\u class=org.hibernate.cache.ehcache.EhCacheRegionFactory
net.sf.ehcache.configurationResourceName=ehcache.xml
**hibernate.dbcp.initialSize=10
hibernate.dbcp.maxActive=100
hibernate.dbcp.maxIdle=30
hibernate.dbcp.minIdle=10**
请建议:-

  • 以粗体标记的属性(initialSize、maxActive、maxidle、minIdle)中的任何更改。我的应用程序将有大约100个用户同时使用,总用户数约为3000
  • 我正在使用Tomcat服务器部署我的应用程序。我应该使用JNDI进行连接,而不是直接指定连接属性吗?上述使用连接的方法是否适用于生产系统

  • 我建议使用(我最近在这方面有很好的经验,或者如果您已经在使用tomcat的话)

    有很多关于池大小的文章(请参阅,以获得一个很好的解释和Oracle的一个简短视频)。简言之,大型池大小不起作用,可能会使性能更差

    经验法则/公式(也在文章中提到)是

    连接=((芯数*2)+有效芯数)


    其中,
    core\u count
    是(实际)的数量服务器中的核心数和有效的磁盘数。如果服务器有一个大磁盘和4个核心,则会导致连接池大小为9。这应该能够处理您需要的内容,添加更多只会增加监控、线程切换等开销。

    而不是我建议的公用程序。Al这是一个很好的解释池大小和为什么大池大小不能工作/扩展,甚至会减慢你的应用程序。你能帮我解决这个问题吗