Cloud Foundry绑定服务/杯子数据源的连接数 [英] Cloud Foundry Bind services/cups datasource number of connections

查看:118
本文介绍了Cloud Foundry绑定服务/杯子数据源的连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有弹簧靴的hikari,进行本地测试时可以看到50个活动连接。部署到Cloud Foundry之后,我只能看到10个活动连接。

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

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?

也许有人可以从此链接中获得帮助,它说如果您正在生产中运行严重的应用程序,则需要配置DataSourceConfiguration

maybe someone get help from this link, it says if you are running serious application in production , you need to configure DataSourceConfiguration

http://cloud.spring.io/spring-cloud-connectors/spring-cloud-spring-service-connector.html#_relational_database_db2_mysql_oracle_oracle_postgresql_sql_server

https://spring.io/blog/2015/04/27/binding-to-data-services-with-spring-boot-in-cloud-foundry

推荐答案

如果在项目中包含 spring-boot-starter-cloud-connectors ,则Spring Boot数据库不使用属性。除非您编写Java代码手动配置它,否则Spring Cloud Connectors将自动创建和配置 Datasource bean。

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

如果您要使用Boot属性而不是像这样编写代码,则可以从项目中删除 spring-boot-starter-cloud-connectors 并使用 vcap 属性应用程序在CF上运行。如果以这种方式配置连接,则应该尊重您的最大池大小属性。

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.

这篇关于Cloud Foundry绑定服务/杯子数据源的连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆