New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default JDBC connection pool to Hikari #6013

Closed
wilkinsona opened this Issue May 23, 2016 · 8 comments

Comments

Projects
None yet
6 participants
@wilkinsona
Member

wilkinsona commented May 23, 2016

2.0 gives us an opportunity to re-evaluate the default connection pool. We currently use Tomcat JDBC. That's a bit awkward when a war's deployed to Tomcat (tomcat-jdbc is always on the classpath). There's also some evidence that HikariCP performs much better.

@benelog

This comment has been minimized.

Show comment
Hide comment
@benelog

benelog May 27, 2016

As you may know, DBCP2 is default connection pool library from Tomcat 8.0.
(
https://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html#Database_Connection_Pool_%28DBCP_2%29_Configurations

The default database connection pool implementation in Apache Tomcat relies on the libraries from the Apache Commons project. The following libraries are used:

  • Commons DBCP
  • Commons Pool

)
It is repackaged into org.apache.tomcat.dbcp.dbcp2.

I am wondering about why tomcat-jdbc is not default connection pool even in Tomcat. The reason can be helpful to the choice of Spring Boot 2.0. I guess that it is because of DBCP2's reliability and stability.

benelog commented May 27, 2016

As you may know, DBCP2 is default connection pool library from Tomcat 8.0.
(
https://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html#Database_Connection_Pool_%28DBCP_2%29_Configurations

The default database connection pool implementation in Apache Tomcat relies on the libraries from the Apache Commons project. The following libraries are used:

  • Commons DBCP
  • Commons Pool

)
It is repackaged into org.apache.tomcat.dbcp.dbcp2.

I am wondering about why tomcat-jdbc is not default connection pool even in Tomcat. The reason can be helpful to the choice of Spring Boot 2.0. I guess that it is because of DBCP2's reliability and stability.

@brettwooldridge

This comment has been minimized.

Show comment
Hide comment
@brettwooldridge

brettwooldridge Jul 5, 2016

Contributor

@wilkinsona HikariCP would be honored to become the default pool in spring-boot. If any issues turn up in your test suites, please let me know.

Contributor

brettwooldridge commented Jul 5, 2016

@wilkinsona HikariCP would be honored to become the default pool in spring-boot. If any issues turn up in your test suites, please let me know.

@wilkinsona wilkinsona changed the title from Reevaluate the default JDBC connection pool to Change the default JDBC connection pool to Hikari Aug 30, 2016

@philwebb philwebb modified the milestones: 2.0.0.M1, 2.0.0, 2.0.0.M4 Jan 12, 2017

@snicoll snicoll modified the milestones: 2.0.0.M1, 2.0.0.M4 Apr 13, 2017

@snicoll snicoll self-assigned this Apr 13, 2017

@nekperu15739

This comment has been minimized.

Show comment
Hide comment
@nekperu15739

nekperu15739 Apr 25, 2017

@wilkinsona are the any way to re-order the list programatically o by config? We are actually building and starter with Hikari dependency. However when an app include own starter and tomcat-pool obviously spring boot chose the second one. I try register programatically by using BeanDefinitionRegistryPostProcessor and BeanPostProcessor without success

nekperu15739 commented Apr 25, 2017

@wilkinsona are the any way to re-order the list programatically o by config? We are actually building and starter with Hikari dependency. However when an app include own starter and tomcat-pool obviously spring boot chose the second one. I try register programatically by using BeanDefinitionRegistryPostProcessor and BeanPostProcessor without success

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll Apr 25, 2017

Member

@nekperu15739 we don't use the tracker for questions. Please join us on Gitter or ask on stackoverflow (but quickly there is a spring.datasource.type property for that).

Member

snicoll commented Apr 25, 2017

@nekperu15739 we don't use the tracker for questions. Please join us on Gitter or ask on stackoverflow (but quickly there is a spring.datasource.type property for that).

@nekperu15739

This comment has been minimized.

Show comment
Hide comment
@nekperu15739

nekperu15739 Apr 25, 2017

thank you @snicoll for the tip, i already try defining spring.datasource.type on the starter using BeanPostProcessor over the DataSourceProperties.class without results. I believe all this become with the no avality of set the Pool order.

nekperu15739 commented Apr 25, 2017

thank you @snicoll for the tip, i already try defining spring.datasource.type on the starter using BeanPostProcessor over the DataSourceProperties.class without results. I believe all this become with the no avality of set the Pool order.

@snicoll snicoll closed this in 800eb01 Apr 27, 2017

@wilkinsona

This comment has been minimized.

Show comment
Hide comment
@wilkinsona

wilkinsona May 13, 2017

Member

It looks like DataSourceBuilder was missed:

private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
			"org.apache.tomcat.jdbc.pool.DataSource",
			"com.zaxxer.hikari.HikariDataSource",
			"org.apache.commons.dbcp2.BasicDataSource" };
Member

wilkinsona commented May 13, 2017

It looks like DataSourceBuilder was missed:

private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
			"org.apache.tomcat.jdbc.pool.DataSource",
			"com.zaxxer.hikari.HikariDataSource",
			"org.apache.commons.dbcp2.BasicDataSource" };

@wilkinsona wilkinsona reopened this May 13, 2017

@nekperu15739

This comment has been minimized.

Show comment
Hide comment
@nekperu15739

nekperu15739 May 13, 2017

I think that magic that comes with DataSourceConfiguration using the conditionals comes with the problem of not have the ability of reorder the pool preference.

nekperu15739 commented May 13, 2017

I think that magic that comes with DataSourceConfiguration using the conditionals comes with the problem of not have the ability of reorder the pool preference.

@snicoll snicoll closed this in b2e3c5d May 14, 2017

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll May 14, 2017

Member

Good catch @wilkinsona, thanks!

Member

snicoll commented May 14, 2017

Good catch @wilkinsona, thanks!

snicoll added a commit that referenced this issue Jun 2, 2017

Use HikariCP is jdbc and jpa starters
This commit is a companion of what was done in #6013. As HikariCP is
now the default connection pool, the jdbc and jpa starters no longer
provide `tomcat-jdbc`, but rather `HikariCP`.

Closes gh-9392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment