Code Monkey home page Code Monkey logo

beecp's Introduction

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);
     }
  }
}

Release download

Java7

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>BeeCP</artifactId>
   <version>2.4.7</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
borrowConcurrentSize 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
holdTimeout max hold time in not using 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

beecp's People

Contributors

chris2018998 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.