All Projects → Chris2018998 → Beecp

Chris2018998 / Beecp

Licence: other
A High Performance JDBC Connection Pool

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Beecp

Hikaricp
光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Stars: ✭ 16,146 (+12225.19%)
Mutual labels:  jdbc, connection-pool, high-performance
Spring Boot Data Source Decorator
Spring Boot integration with p6spy, datasource-proxy, flexy-pool and spring-cloud-sleuth
Stars: ✭ 295 (+125.19%)
Mutual labels:  jdbc, connection-pool
Hikari Cp
A Clojure wrapper to HikariCP JDBC connection pool
Stars: ✭ 334 (+154.96%)
Mutual labels:  jdbc, connection-pool
Stormpot
A fast object pool for the JVM
Stars: ✭ 267 (+103.82%)
Mutual labels:  connection-pool, high-performance
Hibernate Springboot
Collection of best practices for Java persistence performance in Spring Boot applications
Stars: ✭ 589 (+349.62%)
Mutual labels:  jdbc, connection-pool
Servicestack.ormlite
Fast, Simple, Typed ORM for .NET
Stars: ✭ 1,532 (+1069.47%)
Mutual labels:  high-performance
Rapidoid
Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework and HTTP Server!
Stars: ✭ 1,571 (+1099.24%)
Mutual labels:  high-performance
Nanolog
Nanolog is an extremely performant nanosecond scale logging system for C++ that exposes a simple printf-like API.
Stars: ✭ 1,710 (+1205.34%)
Mutual labels:  high-performance
Tlaplus
TLC is an explicit state model checker for specifications written in TLA+. The TLA+Toolbox is an IDE for TLA+.
Stars: ✭ 1,618 (+1135.11%)
Mutual labels:  high-performance
Sunengine
SunEngine – site engine with blog, forum and articles sections features support.
Stars: ✭ 130 (-0.76%)
Mutual labels:  high-performance
Shadesmar
Fast C++ IPC using shared memory (with msgpack)
Stars: ✭ 126 (-3.82%)
Mutual labels:  high-performance
Specql
Automatic PostgreSQL CRUD queries
Stars: ✭ 120 (-8.4%)
Mutual labels:  jdbc
X7
x7-repo: simple orm based on spring jdbcTemplate + sqli; x7-reyc: httpClient or httpTemplate + resilience4j for k8s, plus distribution transaction
Stars: ✭ 1,573 (+1100.76%)
Mutual labels:  jdbc
Sqli
orm sql interface, Criteria, CriteriaBuilder, ResultMapBuilder
Stars: ✭ 1,644 (+1154.96%)
Mutual labels:  jdbc
Edgedb Python
EdgeDB Python Driver
Stars: ✭ 113 (-13.74%)
Mutual labels:  high-performance
Actors
Evaluation of API and performance of different actor libraries
Stars: ✭ 125 (-4.58%)
Mutual labels:  high-performance
Zanphp
PHP开发面向C10K+的高并发SOA服务 和RPC服务首选框架
Stars: ✭ 1,451 (+1007.63%)
Mutual labels:  high-performance
Drill
Apache Drill is a distributed MPP query layer for self describing data
Stars: ✭ 1,619 (+1135.88%)
Mutual labels:  jdbc
Threadsx.jl
Parallelized Base functions
Stars: ✭ 126 (-3.82%)
Mutual labels:  high-performance
Nnpack
Acceleration package for neural networks on multi-core CPUs
Stars: ✭ 1,538 (+1074.05%)
Mutual labels:  high-performance

English|中文

BeeCP:A lightweight,high-performance JDBC pool

Maven artifact(Java7)

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>beecp</artifactId>
   <version>3.1.2</version>
</dependency>

Maven artifact(Java6)

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>beecp</artifactId>
   <version>1.6.9</version>
</dependency>

Performance

1: One million Mutil-thread query (10000 threads x 10 times) | Pool type | HikariCP-3.4.5 | beecp-3.0.5_compete|
| --------------- |---------------- | ----------------- |
| Average time(ms) |25.132750 | 0.284550 |

SQL:select 1 from dual

PC:I5-4210M(2.6Hz,dual core4threads),12G memory Java:JAVA8_64 Pool:init-size10,max-size:10

Test log file:JDBCPool2020-11-06.log

Test soruce:https://github.com/Chris2018998/PoolPerformance

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

Test source:HikariCP-benchmark_BeeCP.zip


Example-1
BeeDataSourceConfig config = new BeeDataSourceConfig();
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setJdbcUrl("jdbc:mysql://localhost/test");
config.setUsername("root");
config.setPassword("root");
config.setMaxActive(10);
config.setInitialSize(0);
config.setMaxWait(8000);//ms
//DataSource ds=new BeeDataSource(config);
BeeDataSource ds=new BeeDataSource(config);
Connection con=ds.getConnection();
....

Example-2(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);
     }
  }
}

Features

1:Borrow timeout

2:Fair mode and compete mode for borrowing

3:Proxy object safe close when return

4:Pooled connection cleared when network bad,pooled connection recreate when network restore OK

5:Idle timeout and hold timeout(long time inactively hold by borrower)

6:Connection transaction rollback if exist commit transaction when return

7:Pooled connection closed when exception,then create new one and transfer it to waiter

8:Pooled connection attributes reset when return(autoCommit,transactionIsolation,readonly,catlog,schema,networkTimeout)

9:XADataSource support

10:support self defined connection factory

11:Pool Reset

12:JMX support


Configuration
Field name Description Remark
username JDBC User
password JDBC Password
jdbcUrl DBC URL
driverClassName JDBC driver class name
poolName pool name name auto generated when not set
fairMode boolean indicator for borrow fair mode true:fair mode,false:comepete mode;default is false
initialSize pooled object creation size when pool initialized default is 0
maxActive max size for pooled object instances in pool default is 10
borrowSemaphoreSize borrow concurrent thread size default val=min(maxActive/2,cpu size)
defaultAutoCommit connection transaction open indicator default is true
defaultTransactionIsolation connection default transaction level default is Connection.TRANSACTION_READ_COMMITTED
defaultCatalog
defaultSchema
defaultReadOnly default is false
maxWait max wait time to borrow one connection time unit is ms,default is 8000 ms
idleTimeout max idle time of connection instance in pool time unit is ms,default is 18000 ms
holdTimeout max inactive time hold by borrower time unit is ms,default is 300000 ms
connectionTestSQL connection valid test sql select statement(don't recommand store procedure in select
connectionTestTimeout connection test timeout time unit is second, default is 5 seconds
forceCloseUsingOnClear using connection close indicator true,close directly;false,wait util connection becoming idle,then close it
connectionFactoryClassName object factory class name default is null
enableJmx JMX boolean indicator for pool default is false

DB and driver
DB Driver class jdbc refrence url
Mariadb org.mariadb.jdbc.Driver jdbc:mariadb://localhost/test
MySQL org.mysql.jdbc.Driver jdbc:mysql://localhost/test
Oracle oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@localhost:1521:orcl
MSSQL com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1433;databaseName=test
Postgresql org.postgresql.Driver jdbc:postgresql://localhost:5432/postgres
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].