I am using hikari with spring boot, local testing I can see 50 active connections. After I deployed to cloud foundry , I am only able to see 10 active connections.
spring.datasource.hikari.maximum-pool-size=50
Seems like cloud foundry bind service is trying to overwrite my application's configuration. How can configure this number in cloud foundry?
maybe someone get help from this link, it says if you are running serious application in production , you need to configure DataSourceConfiguration
https://spring.io/blog/2015/04/27/binding-to-data-services-with-spring-boot-in-cloud-foundry
If you are including spring-boot-starter-cloud-connectors
in your project, then the Spring Boot database properties aren't used. Spring Cloud Connectors will create and configure the Datasource
bean automatically, unless you write the Java code to manually configure it.
As you found in the Connectors docs, you can write code like this to configure the connection properties, including pool size.
@Bean
public DataSource dataSource() {
PoolConfig poolConfig = new PoolConfig(5, 30, 3000);
DataSourceConfig dbConfig = new DataSourceConfig(poolConfig, null);
return connectionFactory().dataSource("database-service-name", dbConfig);
}
If you want to use Boot properties instead of writing code like this, you can remove spring-boot-starter-cloud-connectors
from your project and configure the Boot properties using the vcap
properties provided by Boot when apps are run on CF. Your maximum-pool-size
property should be honored if you configure the connection in this way.