Skip to content
forked from lizy2000/BeeCP

High Performance JDBC Connection Pool(faster than HikariCP : 比光连接池更快)

Notifications You must be signed in to change notification settings

zouyanjian/BeeCP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

Introduction

BeeCP is a high performance JDBC connection pool

中文

Feature

1: Good performance: faster than HikariCP

2: Less code: 21 files, 2600 lines of source code

Performance

1: One million times borrow tests[1000 X 1000],time scope:[datasource.getConnection(),connection.close()]

Time(ms) HikariC3.3.1 Bee_F(BeeCP-2.3.2) Bee_C(BeeCP-2.3.2)
Total time 151516 53384 142
Avg time 0.1515 0.0534 0.0001

Bee_F:Fair Mode Pool,Bee_C:Compete Mode Pool

Total time=Thread1 time + Thread2 time + ...... + Thread1000 time, Avg time = Total time/1000000

PC: Win7 I3-7100 8G mysql5.6.46_64, Pool Setting: init size10, max size:10

DB restart after every test,log file:20200417_JDBCPool_I37100.log

project for performance test code,please visit:https://github.com/Chris2018998/PoolPerformance

2:Test with HikariCP benchmark(I3-7100,8G)

Download HikariCP-benchmark_BeeCP.zip

Demo(SpringBoot)

application.properties

spring.datasource.username=xx
spring.datasource.password=xx
spring.datasource.url=xx
spring.datasource.driverClassName=xxx 
spring.datasource.datasourceJndiName=xxx

DataSourceConfig.java

@Configuration
public class DataSourceConfig {
  @Value("${spring.datasource.driverClassName}")
  private String driver;
  @Value("${spring.datasource.url}")
  private String url;
  @Value("${spring.datasource.username}")
  private String user;
  @Value("${spring.datasource.password}")
  private String password;
  @Value("${spring.datasource.datasourceJndiName}")
  private String datasourceJndiName;
  private BeeDataSourceFactory dataSourceFactory = new BeeDataSourceFactory();
  
  @Bean
  @Primary
  @ConfigurationProperties(prefix="spring.datasource")
  public DataSource primaryDataSource() {
    return DataSourceBuilder.create().type(cn.beecp.BeeDataSource.class).build();
  }
  
  @Bean
  public DataSource secondDataSource(){
    return new BeeDataSource(new BeeDataSourceConfig(driver,url,user,password));
  }
  
  @Bean
  public DataSource thirdDataSource()throws SQLException {
    try{
       return dataSourceFactory.lookup(datasourceJndiName);
     }catch(NamingException e){
       throw new SQLException("Jndi DataSource not found:"+datasourceJndiName);
     }
  }
}

Maven download

Java7

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>BeeCP</artifactId>
   <version>2.4.0</version>
</dependency>

Java6

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>BeeCP</artifactId>
   <version>1.6.7</version>
</dependency>

Friendly tips: the latest version is recommended

Function List

1: Request timeout support

2: Two modes: fairness and competition

3: Pool recreate new connections when network restore

4: Idle timeout and holding timeout

5: Preparedstatement cache support (optional)

6: Before connection recovery, things can be rolled back

7: Support property reset before connection recycling (for example: autocommit, transactionisolation, readonly, Catlog, schema, networktimeout)

8: JMX support

9: Support connection factory customization

Configuration

Configuration item Description remark
username JDBC username
password JDBC password
jdbcUrl JDBC url
driverClassName Driver class name
poolName Pool name
fairMode fair mode for pool default is false
initialSize pool initial size
maxActive pool max size
concurrentSize borrower thread concurrent size not greater than 'maxActive'
preparedStatementCacheSize statment cache size 0 cache is invalid
defaultAutoCommit default autoCommit default is true
defaultTransactionIsolation trasaction level default:Connection.TRANSACTION_READ_COMMITTED
defaultCatalog
defaultSchema
defaultReadOnly default is false
maxWait max wait time to borrow a connection(mills) default is 8 seconds
idleTimeout max idle time in pool(mills) default is 3 minutes
holdIdleTimeout max hold idle time in pool(mills) default is 5 minutes
connectionTestSQL Connection valid test sql a 'select' statment
connectionTestTimeout Connection valid test timeout(seconds) default 5 seconds
connectionTestInterval connection valid test interval time(mills) default 500ms
forceCloseConnection connection close force ind default is false,true:close using directly,false:close using when it is idle
waitTimeToClearPool wait time to clean when exist using conneciton(seconds) default is 3 seconds
idleCheckTimeInterval idle check time interval(mills)
idleCheckTimeInitDelay idle check thread delay time to check first
connectionFactoryClassName Custom JDBC connection factory class name default is null
enableJMX JMX Ind

About

High Performance JDBC Connection Pool(faster than HikariCP : 比光连接池更快)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.9%
  • TSQL 0.1%